---
title: "Generate chat completion (deprecated)"
method: POST
path: "/api/ai/chat/completion"
tags: ["Client"]
deprecated: true
---

# Generate chat completion (deprecated)

`POST /api/ai/chat/completion`

> **Deprecated.**

Deprecated compatibility proxy. New integrations should call https://openrouter.ai/api/v1/chat/completions directly with the provisioned OpenRouter key.

## Request body

- ChatRequest
  - `model` string, required — OpenRouter model identifier
  - `messages` ChatMessage[], required — Array of messages for conversation (supports text, images, audio, and files/PDFs)
    - `role` 'user' | 'assistant' | 'system' | 'tool', required — Role of the message sender
    - `content` string, nullable — Message content (nullable for assistant messages with tool_calls)
    - `tool_calls` ToolCall[] — Tool calls made by the assistant (assistant messages only)
      - `id` string, required — Unique identifier for this tool call
      - `type` 'function', required
      - `function` object, required
        - `name` string, required — The name of the function called
        - `arguments` string, required — JSON string of the function arguments
    - `tool_call_id` string — ID of the tool call being responded to (tool messages only)
  - `stream` boolean — Enable streaming response via Server-Sent Events
  - `temperature` number — Controls randomness in generation
  - `maxTokens` integer — Maximum number of tokens to generate
  - `topP` number — Nucleus sampling parameter
  - `webSearch` WebSearchPlugin
    - `enabled` boolean, required — Enable web search integration
    - `engine` 'native' | 'exa' — Search engine selection: - native: Use provider's built-in web search (OpenAI, Anthropic, Perplexity, xAI) - exa: Use Exa's search API - undefined: Auto-select (native if available, otherwise Exa)
    - `maxResults` integer — Maximum number of search results to include
    - `searchPrompt` string — Custom prompt for attaching search results to the message
  - `fileParser` FileParserPlugin
    - `enabled` boolean, required — Enable file parsing for PDFs in messages
    - `pdf` object
      - `engine` 'pdf-text' | 'mistral-ocr' | 'native' — PDF processing engine: - pdf-text: Best for well-structured PDFs with clear text content (Free) - mistral-ocr: Best for scanned documents or PDFs with images ($2 per 1,000 pages) - native: Only for models with native file support (charged as input tokens) If not specified, defaults to native if available, otherwise mistral-ocr
  - `thinking` boolean — Enable extended reasoning capabilities (appends :thinking to model ID if not already present). Not every model supports this, only works with Anthropic models with the :thinking suffix.
  - `tools` Tool[] — Tool definitions for function calling
    - `type` 'function', required
    - `function` FunctionDefinition, required
      - `name` string, required — The name of the function to call
      - `description` string — A description of what the function does
      - `parameters` object — JSON Schema describing the function parameters
  - `toolChoice` union — Controls tool usage: auto, none, required, or a specific function
    - 'auto' | 'none' | 'required'
    - object
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
  - `parallelToolCalls` boolean — Allow the model to call multiple tools in parallel

## Response `200`

Chat completion response

- ChatCompletionResponse
  - `text` string — AI model response content
  - `tool_calls` ToolCall[] — Tool calls requested by the model (present when the model invokes tools)
    - `id` string, required — Unique identifier for this tool call
    - `type` 'function', required
    - `function` object, required
      - `name` string, required — The name of the function called
      - `arguments` string, required — JSON string of the function arguments
  - `annotations` UrlCitationAnnotation[] — URL citations from web search results (present when webSearch is enabled)
    - `type` 'url_citation'
    - `urlCitation` object
      - `url` string — URL of the cited source
      - `title` string — Title of the cited page
      - `content` string — Relevant content snippet from the source
      - `startIndex` integer — Start character index in response text where citation applies
      - `endIndex` integer — End character index in response text where citation applies
  - `metadata` object
    - `model` string
    - `usage` TokenUsage
      - `promptTokens` integer
      - `completionTokens` integer
      - `totalTokens` integer

## Other responses

- `400` — Invalid request - missing model or messages
- `401` — Unauthorized
- `500` — Failed to get response

---

[API](https://skmtc.net/insforge/apis/insforge-authentication-api.md) · [All operations](https://skmtc.net/insforge/apis/insforge-authentication-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/insforge/insforge-authentication-api/versions/a935bb49f932/schema)
