---
title: "Create completion"
method: POST
path: "/v2/router/completions"
tags: ["Completions"]
---

# Create completion

`POST /v2/router/completions`

For sending requests to legacy completion models

## Request body

- object
  - `model` string, required — ID of the model to use
  - `prompt` string, required — The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
  - `echo` boolean, nullable — Echo back the prompt in addition to the completion
  - `frequency_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
  - `max_tokens` integer, nullable — The maximum number of tokens that can be generated in the completion.
  - `presence_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
  - `seed` integer, nullable — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
  - `stop` union — Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
    - string
    - string[]
  - `temperature` number, nullable — What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
  - `top_p` number, nullable — An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
  - `n` integer, nullable — How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota.
  - `user` string — A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
  - `name` string — The name to display on the trace. If not specified, the default system name will be used.
  - `fallbacks` object[] — Array of fallback models to use if primary model fails
    - `model` string, required — Fallback model identifier
  - `retry` object — Retry configuration for the request
    - `count` number — Number of retry attempts (1-5)
    - `on_codes` number[] — HTTP status codes that trigger retry logic
  - `cache` object — Cache configuration for the request.
    - `ttl` number — Time to live for cached responses in seconds. Maximum 259200 seconds (3 days).
    - `type` 'exact_match', required
  - `load_balancer` object — Load balancer configuration for the request.
    - `type` 'weight_based', required
    - `models` object[], required
      - `model` string, required — Model identifier for load balancing
      - `weight` number — Weight assigned to this model for load balancing
  - `timeout` object — Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured.
    - `call_timeout` number, required — Timeout value in milliseconds
  - `thinking` union — Configuration for the thinking mode capability. Set type to `adaptive` for models that support adaptive thinking (e.g. Claude Opus 4.6, Sonnet 4.6), or `enabled` with `budget_tokens` for manual control.
    - ThinkingConfigDisabledSchema — Disables the thinking mode capability
      - `type` 'disabled', required — Disables the thinking mode capability
    - ThinkingConfigEnabledSchema — Enables the thinking mode capability
      - `type` 'enabled', required — Enables or disables the thinking mode capability
      - `budget_tokens` number, required — Determines how many tokens the model can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`.
      - `thinking_level` 'minimal' | 'low' | 'medium' | 'high' — The level of reasoning the model should use. This setting is supported only by `gemini-3` models. If budget_tokens is specified and `thinking_level` is available, `budget_tokens` will be ignored.
    - ThinkingConfigAdaptiveSchema — Enables adaptive thinking mode where the model dynamically determines thinking depth
      - `type` 'adaptive', required — Lets the model dynamically determine when and how much to use extended thinking based on the complexity of each request. Supported on Claude Opus 4.6 and Sonnet 4.6.
  - `plugins` union[] — Request-scoped transforms applied to the text exchanged with the model. Currently supports `pii_redaction`, which replaces PII with placeholders before the provider sees it and restores the original values in the response.
    - union
      - PIIRedactionPluginAuto
        - `id` 'pii_redaction', required — Plugin discriminator. Must be `pii_redaction`.
        - `on_failure` 'block' | 'passthrough' — Behavior when redaction is unavailable. `block` (default) fails the request; `passthrough` sends the original text.
        - `threshold` number — Detector confidence cutoff in [0,1].
        - `entities` string[] — Entity types to redact when no detector language is configured. Omit to redact every detected type.
      - PIIRedactionPluginEn
        - `id` 'pii_redaction', required — Plugin discriminator. Must be `pii_redaction`.
        - `on_failure` 'block' | 'passthrough' — Behavior when redaction is unavailable. `block` (default) fails the request; `passthrough` sends the original text.
        - `threshold` number — Detector confidence cutoff in [0,1].
        - `language` 'en', required — Detector language.
        - `entities` string[] — English entity types to redact. Omit to redact every type detected for the language.
      - PIIRedactionPluginNl
        - `id` 'pii_redaction', required — Plugin discriminator. Must be `pii_redaction`.
        - `on_failure` 'block' | 'passthrough' — Behavior when redaction is unavailable. `block` (default) fails the request; `passthrough` sends the original text.
        - `threshold` number — Detector confidence cutoff in [0,1].
        - `language` 'nl', required — Detector language.
        - `entities` string[] — Dutch entity types to redact. Omit to redact every type detected for the language.
  - `orq` object — Leverage Orq's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution.
    - `name` string — The name to display on the trace. If not specified, the default system name will be used.
    - `retry` object — Retry configuration for the request
      - `count` number — Number of retry attempts (1-5)
      - `on_codes` number[] — HTTP status codes that trigger retry logic
    - `fallbacks` object[] — Array of fallback models to use if primary model fails
      - `model` string, required — Fallback model identifier
    - `prompt` object — Prompt configuration for the request
      - `id` string, required — Unique identifier of the prompt to use
      - `version` 'latest', required — Version of the prompt to use (currently only "latest" supported)
    - `identity` PublicIdentity — Information about the identity making the request. If the identity does not exist, it will be created automatically.
      - `id` string, required — Unique identifier for the contact
      - `display_name` string — Display name of the contact
      - `email` string, email — Email address of the contact
      - `metadata` object[] — A hash of key/value pairs containing any other data about the contact
      - `logo_url` string — URL to the contact's avatar or logo
      - `tags` string[] — A list of tags associated with the contact
    - `contact` PublicContact — @deprecated Use identity instead. Information about the contact making the request.
      - `id` string, required — Unique identifier for the contact
      - `display_name` string — Display name of the contact
      - `email` string, email — Email address of the contact
      - `metadata` object[] — A hash of key/value pairs containing any other data about the contact
      - `logo_url` string — URL to the contact's avatar or logo
      - `tags` string[] — A list of tags associated with the contact
    - `thread` object — Thread information to group related requests
      - `id` string, required — Unique thread identifier to group related invocations.
      - `tags` string[] — Optional tags to differentiate or categorize threads
    - `inputs` union — @deprecated Use top-level `variables` field instead. Values to replace in the prompt messages using {{variableName}} syntax.
      - object
      - object[]
        - `key` string, required
        - `value` unknown
        - `is_pii` boolean
    - `cache` object — Cache configuration for the request.
      - `ttl` number — Time to live for cached responses in seconds. Maximum 259200 seconds (3 days).
      - `type` 'exact_match', required
    - `knowledge_bases` object[]
      - `top_k` integer, nullable — The number of results to return. Send `null` or omit to use the knowledge base configured `top_k`.
      - `threshold` number, nullable — The threshold to apply to the search. Send `null` or omit to use the knowledge base configured `threshold`
      - `search_type` 'vector_search' | 'keyword_search' | 'hybrid_search' | 'null', nullable — The type of search to perform. Send `null` or omit to use the knowledge base configured `retrieval_type`
      - `filter_by` union — The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://docs.orq.ai/docs/knowledge/api#knowledge-base-search) for more information.
        - object
        - object — And
          - `and` object[], required
        - object — Or
          - `or` object[], required
      - `search_options` object — Additional search options
        - `include_vectors` boolean — Whether to include the vector in the chunk
        - `include_metadata` boolean — Whether to include the metadata in the chunk
        - `include_scores` boolean — Whether to include the scores in the chunk
      - `rerank_config` object — Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings.
        - `model` string, required — The name of the rerank model to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/rerank-models).
        - `threshold` number — The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned
        - `top_k` integer — The number of top results to return after reranking. Defaults to `10`.
      - `agentic_rag_config` object — Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings.
        - `model` string, required — The name of the model for the Agent to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/chat-models).
      - `knowledge_id` string, required — Unique identifier of the knowledge base to search
      - `query` string — The query to use to search the knowledge base. If not provided we will use the last user message from the messages of the requests
    - `load_balancer` object — Array of models with weights for load balancing requests
      - `type` 'weight_based', required
      - `models` object[], required
        - `model` string, required — Model identifier for load balancing
        - `weight` number — Weight assigned to this model for load balancing
    - `timeout` object — Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured.
      - `call_timeout` number, required — Timeout value in milliseconds
  - `stream` boolean

## Response `200`

Represents a completion response from the API.

- object
  - `id` string, required — A unique identifier for the completion.
  - `choices` object[], required — The list of completion choices the model generated for the input prompt.
    - `finish_reason` 'stop' | 'length' | 'content_filter' | 'tool_calls', required — The reason the model stopped generating tokens.
    - `index` number, required — The index of the choice in the list of choices.
    - `text` string, required
  - `created` union — The Unix timestamp (in seconds) of when the chat completion was created.
    - string
    - number
  - `model` string, required — The model used for the chat completion.
  - `system_fingerprint` string — This fingerprint represents the backend configuration that the model runs with.
  - `object` string, required — The object type
  - `usage` object — Usage statistics for the completion request.
    - `completion_tokens` number — Number of tokens in the generated completion.
    - `prompt_tokens` number — Number of tokens in the prompt.
    - `total_tokens` number — Total number of tokens used in the request (prompt + completion).
    - `prompt_tokens_details` object, nullable
      - `cached_tokens` integer, nullable
      - `cache_creation_tokens` integer, nullable
      - `audio_tokens` integer, nullable — The number of audio input tokens consumed by the request.
    - `completion_tokens_details` object, nullable
      - `reasoning_tokens` number, nullable
      - `accepted_prediction_tokens` number, nullable
      - `rejected_prediction_tokens` number, nullable
      - `audio_tokens` integer, nullable — The number of audio output tokens produced by the response.

---

[API](https://skmtc.net/orq-ai/apis/orq-ai-api.md) · [All operations](https://skmtc.net/orq-ai/apis/orq-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/orq-ai/orq-ai-api/revisions/f7a624eccddb/schema)
