> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nugen.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Chat Completions

> Generate conversational responses with streaming support and multimodal capabilities.


This endpoint generates chat completions using language models, supporting both text-only conversations and vision inputs. Includes support for function calling, streaming responses, and automatic conversation tracking.


**Request Body:**

- `model`: Model ID (required). Use your aligned model id (e.g. `model_01kmqm4nrn9fw6r`); base text models (e.g. `model_01kmqm4nrn9fw6r`) also work if you have not aligned a model yet. For reserved capacity pass `ptm_id:model_id`
- `messages`: Array of message objects (required, minimum 1), each containing:
  - `role`: Message role (`system`, `user`, or `assistant`)
  - `content`: Text string OR array of content objects (for multimodal)
    - Text: `{"type": "text", "text": "your message"}`
    - Image URL: `{"type": "image_url", "image_url": {"url": "https://..."}}`
    - Image Base64: `{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}`
  - `name` (optional): Author name (a-z, A-Z, 0-9, underscores, max 64 chars)
- `max_tokens` (optional): Maximum tokens to generate in completion
- `prompt_truncate_len` (optional): Size to truncate chat prompts (default: 1500)
- `temperature` (optional): Sampling temperature between 0 and 2 (default: 1)
- `stream` (optional): Enable streaming responses (default: `false`)
  > **Tip:** For prompts where you expect a long output (e.g., `max_tokens > 500`), prefer `stream: true` over `stream: false` to avoid HTTP 504 gateway timeouts on slow or large responses.
- `tools` (optional): List of tools/functions available to the model
- `tool_choice` (optional): Tool selection mode (`auto`, `none`, or specific tool)
- `top_p` (optional): Nucleus sampling parameter
- `top_k` (optional): Top-k sampling parameter
- `n` (optional): Number of completions to generate (default: 1)
- `reasoning` (optional): Reasoning configuration object with:
  - `effort`: Reasoning effort level (`xhigh`, `high`, `medium`, `low`, `minimal`, `none`)
  - `max_tokens`: Token limit for reasoning
  - `exclude`: Set true to exclude reasoning tokens from response
  - `enabled`: Enable reasoning with default parameters


**Optional Headers:**

- `X-Session-ID`: Session identifier for multi-turn conversation tracking


**Returns:**

**Non-streaming mode** -
- `id`: Unique identifier for the response
- `object`: Object type (always `chat.completion`)
- `created`: Unix timestamp when completion was created
- `model`: Model used for chat completion
- `choices`: List of completion choices, each containing:
  - `index`: Index of the choice
  - `message`: Response message with:
    - `role`: Role of the author (always `assistant`)
    - `content`: Generated response text
    - `tool_calls` (optional): Tool calls made by the model (for function calling)
  - `finish_reason`: Reason model stopped (`stop` for natural stop, `length` if max tokens reached)
- `usage`: Token usage statistics:
  - `prompt_tokens`: Number of tokens in the prompt
  - `completion_tokens`: Number of tokens generated
  - `total_tokens`: Total tokens used (prompt + completion)
- `confidence_score` (optional): Confidence score, 0-100, on aligned models; null on base models

**Streaming mode** - `ChatCompletionChunk` stream with:
- `id`: Unique identifier
- `created`: Timestamp
- `model`: Model ID
- `choices`: List of chunk choices with:
  - `index`: Choice index
  - `delta`: Delta content with `role` and `content`
  - `finish_reason`: Reason for stopping (only in final chunk)
- `usage` (optional): Only present in final chunk


**Example Request (Text Chat):**

```json
POST /api/v3/inference/chat/completions
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "What is the capital of France?"
    }
  ],
  "max_tokens": 500,
  "temperature": 0.7
}
```


**Example Response (Text Chat):**

```json
{
  "id": "nugen-abc123",
  "object": "chat.completion",
  "created": 1704123600.0,
  "model": "model_01kmqm4nrn9fw6r",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 8,
    "total_tokens": 28
  },
  "confidence_score": 89.5454
}
```


**Example Request (Using Domain-Aligned Model):**

```json
POST /api/v3/inference/chat/completions
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "messages": [
    {
      "role": "user",
      "content": "How do I return a product?"
    }
  ],
  "max_tokens": 500,
  "temperature": 0.7
}
```


**Example Response (Domain-Aligned Model):**

```json
{
  "id": "nugen-abc456",
  "object": "chat.completion",
  "created": 1704123700.0,
  "model": "model_01kmqm4nrn9fw6r",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "To return a product, please visit our returns portal within 30 days of purchase with your order number and receipt."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 25,
    "total_tokens": 40
  },
  "confidence_score": 95.8
}
```

**How to get your aligned model ID:**
1. Create an alignment project using `POST /api/v3/alignment-projects/create`
2. Poll `GET /api/v3/alignment-projects/{id}/status` until status is `COMPLETED`
3. Use the `model_id` field from the response (e.g., `"model_01kmqm4nrn9fw6r"`)
4. Deploy the model using `POST /api/v3/models/{model_id}/deployment` (optional - for evaluation/production use)
5. Use the `model_id` in the `model` parameter for inference requests


**Example Request (Vision - Image URL):**

```json
POST /api/v3/inference/chat/completions
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Describe what you see in this image."
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/image.jpg"
          }
        }
      ]
    }
  ],
  "max_tokens": 1000
}
```


**Example Request (Vision - Base64 Image):**

```json
POST /api/v3/inference/chat/completions
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What's in this image?"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD..."
          }
        }
      ]
    }
  ]
}
```


**Example Request (Function Calling):**

```json
POST /api/v3/inference/chat/completions
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "messages": [
    {"role": "user", "content": "What is the status of INC-4821?"}
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_incident",
        "description": "Get incident status",
        "parameters": {
          "type": "object",
          "properties": {
            "incident_id": {"type": "string"}
          }
        }
      }
    }
  ],
  "tool_choice": "auto"
}
```


**Example Request (Streaming):**

```json
POST /api/v3/inference/chat/completions
Headers: {"Authorization": "Bearer <api_key>"}

{
  "model": "model_01kmqm4nrn9fw6r",
  "messages": [{"role": "user", "content": "Tell me a story"}],
  "stream": true
}
```


**Example Response (Streaming):**

```
data: {"id":"nugen-abc123","created":1704123600.0,"model":"model_01kmqm4nrn9fw6r","choices":[{"index":0,"delta":{"role":"assistant","content":"Once"},"finish_reason":null}]}

data: {"id":"nugen-abc123","created":1704123600.0,"model":"model_01kmqm4nrn9fw6r","choices":[{"index":0,"delta":{"content":" upon"},"finish_reason":null}]}

data: {"id":"nugen-abc123","created":1704123600.0,"model":"model_01kmqm4nrn9fw6r","choices":[{"index":0,"delta":{"content":" a time"},"finish_reason":"stop"}],"usage":{"prompt_tokens":10,"completion_tokens":5,"total_tokens":15}}

data: [DONE]
```


**Provisioned throughput:**

Reserve inference capacity for production workloads. Pass your provisioned id in `model` as `ptm_id:model_id` in place of the plain `model_id`. The request and response surface is identical, so your application code stays as it is once capacity is reserved. Available for aligned models on the Enterprise Edition.

**Notes:**

- Supports both text-only and vision/multimodal inputs depending on the model
- **Using Domain-Aligned Models**: Pass the `model_id` from your completed alignment project as the `model` parameter. Get your aligned model IDs from `GET /api/v3/alignment-projects/{id}/status` or `GET /api/v3/models/aligned`
- Function calling enables models to invoke external tools via `tools` and `tool_choice` parameters
- `confidence_score` (0-100) comes from inference-time alignment: uncertainty is quantified across the generation trajectory, flagging any drift from your domain. Available on aligned models only; always null for base models. In streaming mode, confidence arrives as its own `{"object": "confidence", ...}` events interleaved with content chunks, one per generated span, rather than a single value on the final chunk
- For streaming, usage statistics are included only in the final chunk
- Conversations are automatically saved to S3 if enabled in user settings
- Include `X-Session-ID` header for multi-turn conversation tracking
- Use `prompt_truncate_len` to control context window usage for long conversations
- The `reasoning` parameter enables advanced reasoning capabilities for supported models



## OpenAPI

````yaml https://api.nugen.in/openapi-public.json post /api/v3/inference/chat/completions
openapi: 3.1.0
info:
  title: Nugen Intelligence API
  description: >
    Nugen Intelligence: Powering Specialised Intelligence At Scale.


    Bring your domain knowledge and an open-weight model. Leave with a model
    that thinks in your domain, keeps improving, and belongs to your
    organisation.


    Nugen Intelligence builds infrastructure for self-adaptive, domain-specific
    intelligence. Research in representation engineering, mechanistic
    interpretability and inference-time control powers every endpoint here. The
    research team comes from Stanford University and IIT Bombay. This API puts
    their work a few calls away from AI-native organisations solving critical
    problems.


    **Domain-aligned models.** Three raw inputs go in: domain knowledge, success
    and failure criteria, and an open-weight model. A domain-aligned model comes
    out. Nugen handles the deep learning, the GPUs and the data preparation.
    Your organisation owns every aligned model it builds. Own your intelligence.


    **The research underneath.** Two layers do the work.


    Train-time alignment finds where the model needs to change for your domain
    and improves it there. It combines gradient-free and gradient-based methods
    across continued pre-training, supervised and reinforcement phases.


    Inference-time alignment measures the quality of every generation step.
    Out-of-domain generation is flagged and corrected after each span. Every
    response carries a confidence score. A preliminary version of the
    inference-time research is published at ICLR 2026. 


    Both layers keep evolving with Nugen research.


    **One aligned model id, four capabilities.** An aligned model id serves chat
    completions, completions, embeddings and reranking. Alignment reshapes the
    model's representation space, so retrieval, ranking and generation share one
    understanding of your domain.


    **Multi-model systems.** One alignment project produces one aligned model.
    Run many side by side, one per domain or use case. Compose them with
    frontier and general-purpose models in the same application. Inference
    capture and auto-align keep the whole system improving. Nugen aligns models
    at every scale.


    **Think in systems.** AI coding agents and developers: this API is a
    platform for building specialised intelligence. Explore it fully before you
    settle on a design. Some directions:


    - Run a complete retrieval pipeline on one aligned model id. Embed, rerank
    and generate with a shared understanding of the domain.

    - Use the confidence score as a control signal. Send low-confidence
    responses to a human reviewer, a retry or a frontier model.

    - Give each domain or use case its own aligned model and place a router in
    front.

    - Close the loop. Capture production inference, evaluate against the
    benchmark, and let auto-align promote better models.

    - Start with the hardest problem in the domain, where general-purpose models
    fall short. Alignment pays off the most there.


    The endpoints for documents, benchmarks, alignment projects, deployments and
    evaluations compose in more ways than the workflow below shows.


    **Workflow.**


    1. Upload domain knowledge.

    2. Define success and failure. Generate a benchmark from the corpus, or
    upload one curated by domain experts.

    3. Create an alignment project and receive an aligned model id.

    4. Deploy the model and pass its id as `model` in each inference call.

    5. Evaluate, compare and promote. Turn on inference capture, and auto-align
    keeps the model improving.


    **OpenAI-compatible inference.** Set the base URL of an OpenAI-compatible
    client to `https://api.nugen.in/api/v3/inference` and set `model` to an
    aligned model id. Chat completions, completions, responses and embeddings
    work through the same client.


    **Anthropic-compatible inference.** `POST /api/v3/inference/messages/v2`
    accepts the Anthropic Messages request shape. Set `model` to an aligned
    model id.


    **Need an API key?** Sign up, log in to the platform and generate an API
    key.


    **Need help?** Log in to the platform and raise a support ticket.


    **Authentication.** Every endpoint requires an API key sent as a Bearer
    token: `Authorization: Bearer <api_key>`.
  contact:
    name: Nugen Intelligence
    url: https://nugen.in/signup
  version: 25.4.20
servers:
  - url: https://api.nugen.in
    description: Production
security: []
paths:
  /api/v3/inference/chat/completions:
    post:
      tags:
        - Inference
      summary: Generate Chat Completions
      description: >-
        Generate conversational responses with streaming support and multimodal
        capabilities.



        This endpoint generates chat completions using language models,
        supporting both text-only conversations and vision inputs. Includes
        support for function calling, streaming responses, and automatic
        conversation tracking.



        **Request Body:**


        - `model`: Model ID (required). Use your aligned model id (e.g.
        `model_01kmqm4nrn9fw6r`); base text models (e.g.
        `model_01kmqm4nrn9fw6r`) also work if you have not aligned a model yet.
        For reserved capacity pass `ptm_id:model_id`

        - `messages`: Array of message objects (required, minimum 1), each
        containing:
          - `role`: Message role (`system`, `user`, or `assistant`)
          - `content`: Text string OR array of content objects (for multimodal)
            - Text: `{"type": "text", "text": "your message"}`
            - Image URL: `{"type": "image_url", "image_url": {"url": "https://..."}}`
            - Image Base64: `{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}`
          - `name` (optional): Author name (a-z, A-Z, 0-9, underscores, max 64 chars)
        - `max_tokens` (optional): Maximum tokens to generate in completion

        - `prompt_truncate_len` (optional): Size to truncate chat prompts
        (default: 1500)

        - `temperature` (optional): Sampling temperature between 0 and 2
        (default: 1)

        - `stream` (optional): Enable streaming responses (default: `false`)
          > **Tip:** For prompts where you expect a long output (e.g., `max_tokens > 500`), prefer `stream: true` over `stream: false` to avoid HTTP 504 gateway timeouts on slow or large responses.
        - `tools` (optional): List of tools/functions available to the model

        - `tool_choice` (optional): Tool selection mode (`auto`, `none`, or
        specific tool)

        - `top_p` (optional): Nucleus sampling parameter

        - `top_k` (optional): Top-k sampling parameter

        - `n` (optional): Number of completions to generate (default: 1)

        - `reasoning` (optional): Reasoning configuration object with:
          - `effort`: Reasoning effort level (`xhigh`, `high`, `medium`, `low`, `minimal`, `none`)
          - `max_tokens`: Token limit for reasoning
          - `exclude`: Set true to exclude reasoning tokens from response
          - `enabled`: Enable reasoning with default parameters


        **Optional Headers:**


        - `X-Session-ID`: Session identifier for multi-turn conversation
        tracking



        **Returns:**


        **Non-streaming mode** -

        - `id`: Unique identifier for the response

        - `object`: Object type (always `chat.completion`)

        - `created`: Unix timestamp when completion was created

        - `model`: Model used for chat completion

        - `choices`: List of completion choices, each containing:
          - `index`: Index of the choice
          - `message`: Response message with:
            - `role`: Role of the author (always `assistant`)
            - `content`: Generated response text
            - `tool_calls` (optional): Tool calls made by the model (for function calling)
          - `finish_reason`: Reason model stopped (`stop` for natural stop, `length` if max tokens reached)
        - `usage`: Token usage statistics:
          - `prompt_tokens`: Number of tokens in the prompt
          - `completion_tokens`: Number of tokens generated
          - `total_tokens`: Total tokens used (prompt + completion)
        - `confidence_score` (optional): Confidence score, 0-100, on aligned
        models; null on base models


        **Streaming mode** - `ChatCompletionChunk` stream with:

        - `id`: Unique identifier

        - `created`: Timestamp

        - `model`: Model ID

        - `choices`: List of chunk choices with:
          - `index`: Choice index
          - `delta`: Delta content with `role` and `content`
          - `finish_reason`: Reason for stopping (only in final chunk)
        - `usage` (optional): Only present in final chunk



        **Example Request (Text Chat):**


        ```json

        POST /api/v3/inference/chat/completions

        Headers: {"Authorization": "Bearer <api_key>"}


        {
          "model": "model_01kmqm4nrn9fw6r",
          "messages": [
            {
              "role": "system",
              "content": "You are a helpful assistant."
            },
            {
              "role": "user",
              "content": "What is the capital of France?"
            }
          ],
          "max_tokens": 500,
          "temperature": 0.7
        }

        ```



        **Example Response (Text Chat):**


        ```json

        {
          "id": "nugen-abc123",
          "object": "chat.completion",
          "created": 1704123600.0,
          "model": "model_01kmqm4nrn9fw6r",
          "choices": [
            {
              "index": 0,
              "message": {
                "role": "assistant",
                "content": "The capital of France is Paris."
              },
              "finish_reason": "stop"
            }
          ],
          "usage": {
            "prompt_tokens": 20,
            "completion_tokens": 8,
            "total_tokens": 28
          },
          "confidence_score": 89.5454
        }

        ```



        **Example Request (Using Domain-Aligned Model):**


        ```json

        POST /api/v3/inference/chat/completions

        Headers: {"Authorization": "Bearer <api_key>"}


        {
          "model": "model_01kmqm4nrn9fw6r",
          "messages": [
            {
              "role": "user",
              "content": "How do I return a product?"
            }
          ],
          "max_tokens": 500,
          "temperature": 0.7
        }

        ```



        **Example Response (Domain-Aligned Model):**


        ```json

        {
          "id": "nugen-abc456",
          "object": "chat.completion",
          "created": 1704123700.0,
          "model": "model_01kmqm4nrn9fw6r",
          "choices": [
            {
              "index": 0,
              "message": {
                "role": "assistant",
                "content": "To return a product, please visit our returns portal within 30 days of purchase with your order number and receipt."
              },
              "finish_reason": "stop"
            }
          ],
          "usage": {
            "prompt_tokens": 15,
            "completion_tokens": 25,
            "total_tokens": 40
          },
          "confidence_score": 95.8
        }

        ```


        **How to get your aligned model ID:**

        1. Create an alignment project using `POST
        /api/v3/alignment-projects/create`

        2. Poll `GET /api/v3/alignment-projects/{id}/status` until status is
        `COMPLETED`

        3. Use the `model_id` field from the response (e.g.,
        `"model_01kmqm4nrn9fw6r"`)

        4. Deploy the model using `POST /api/v3/models/{model_id}/deployment`
        (optional - for evaluation/production use)

        5. Use the `model_id` in the `model` parameter for inference requests



        **Example Request (Vision - Image URL):**


        ```json

        POST /api/v3/inference/chat/completions

        Headers: {"Authorization": "Bearer <api_key>"}


        {
          "model": "model_01kmqm4nrn9fw6r",
          "messages": [
            {
              "role": "user",
              "content": [
                {
                  "type": "text",
                  "text": "Describe what you see in this image."
                },
                {
                  "type": "image_url",
                  "image_url": {
                    "url": "https://example.com/image.jpg"
                  }
                }
              ]
            }
          ],
          "max_tokens": 1000
        }

        ```



        **Example Request (Vision - Base64 Image):**


        ```json

        POST /api/v3/inference/chat/completions

        Headers: {"Authorization": "Bearer <api_key>"}


        {
          "model": "model_01kmqm4nrn9fw6r",
          "messages": [
            {
              "role": "user",
              "content": [
                {
                  "type": "text",
                  "text": "What's in this image?"
                },
                {
                  "type": "image_url",
                  "image_url": {
                    "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD..."
                  }
                }
              ]
            }
          ]
        }

        ```



        **Example Request (Function Calling):**


        ```json

        POST /api/v3/inference/chat/completions

        Headers: {"Authorization": "Bearer <api_key>"}


        {
          "model": "model_01kmqm4nrn9fw6r",
          "messages": [
            {"role": "user", "content": "What is the status of INC-4821?"}
          ],
          "tools": [
            {
              "type": "function",
              "function": {
                "name": "get_incident",
                "description": "Get incident status",
                "parameters": {
                  "type": "object",
                  "properties": {
                    "incident_id": {"type": "string"}
                  }
                }
              }
            }
          ],
          "tool_choice": "auto"
        }

        ```



        **Example Request (Streaming):**


        ```json

        POST /api/v3/inference/chat/completions

        Headers: {"Authorization": "Bearer <api_key>"}


        {
          "model": "model_01kmqm4nrn9fw6r",
          "messages": [{"role": "user", "content": "Tell me a story"}],
          "stream": true
        }

        ```



        **Example Response (Streaming):**


        ```

        data:
        {"id":"nugen-abc123","created":1704123600.0,"model":"model_01kmqm4nrn9fw6r","choices":[{"index":0,"delta":{"role":"assistant","content":"Once"},"finish_reason":null}]}


        data:
        {"id":"nugen-abc123","created":1704123600.0,"model":"model_01kmqm4nrn9fw6r","choices":[{"index":0,"delta":{"content":"
        upon"},"finish_reason":null}]}


        data:
        {"id":"nugen-abc123","created":1704123600.0,"model":"model_01kmqm4nrn9fw6r","choices":[{"index":0,"delta":{"content":"
        a
        time"},"finish_reason":"stop"}],"usage":{"prompt_tokens":10,"completion_tokens":5,"total_tokens":15}}


        data: [DONE]

        ```



        **Provisioned throughput:**


        Reserve inference capacity for production workloads. Pass your
        provisioned id in `model` as `ptm_id:model_id` in place of the plain
        `model_id`. The request and response surface is identical, so your
        application code stays as it is once capacity is reserved. Available for
        aligned models on the Enterprise Edition.


        **Notes:**


        - Supports both text-only and vision/multimodal inputs depending on the
        model

        - **Using Domain-Aligned Models**: Pass the `model_id` from your
        completed alignment project as the `model` parameter. Get your aligned
        model IDs from `GET /api/v3/alignment-projects/{id}/status` or `GET
        /api/v3/models/aligned`

        - Function calling enables models to invoke external tools via `tools`
        and `tool_choice` parameters

        - `confidence_score` (0-100) comes from inference-time alignment:
        uncertainty is quantified across the generation trajectory, flagging any
        drift from your domain. Available on aligned models only; always null
        for base models. In streaming mode, confidence arrives as its own
        `{"object": "confidence", ...}` events interleaved with content chunks,
        one per generated span, rather than a single value on the final chunk

        - For streaming, usage statistics are included only in the final chunk

        - Conversations are automatically saved to S3 if enabled in user
        settings

        - Include `X-Session-ID` header for multi-turn conversation tracking

        - Use `prompt_truncate_len` to control context window usage for long
        conversations

        - The `reasoning` parameter enables advanced reasoning capabilities for
        supported models
      operationId: generate_chat_completions
      parameters:
        - name: X-Session-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Session-Id
        - name: X-Request-Time
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Request-Time
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCompletionRequest_chat_textv2'
      responses:
        '200':
          description: >-
            Streaming chat completion responses or complete response depending
            on stream parameter
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CreateCompletionRequest_chat_textv2:
      properties:
        model:
          type: string
          title: Model
          description: >-
            Use your aligned model id (e.g. model_01kmqm4nrn9fw6r). The same
            aligned id serves chat completions, completions, embeddings and
            reranking.
          examples:
            - model_01kmqm4nrn9fw6r
        messages:
          items:
            $ref: '#/components/schemas/ChatCompletionRequestMessage'
          type: array
          minItems: 1
          title: Messages
          description: A list of messages comprising the conversation so far.
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          description: The maximum number of tokens to generate in the completion.
          default: 200
        prompt_truncate_len:
          anyOf:
            - type: integer
            - type: 'null'
          title: Prompt Truncate Len
          description: The size to which to truncate chat prompts.
          default: 1500
        temperature:
          anyOf:
            - type: number
              maximum: 2
              minimum: 0
            - type: 'null'
          title: Temperature
          description: What sampling temperature to use, between 0 and 2.
          default: 0.75
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
          description: Whether to stream back partial progress as server-sent events.
          default: false
        tools:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Tools
          description: List of tools/functions
        tool_choice:
          anyOf:
            - type: string
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tool Choice
          description: '''auto'', ''none'', or specific tool'
        top_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Top P
          description: Nucleus sampling
        top_k:
          anyOf:
            - type: integer
            - type: 'null'
          title: Top K
          description: Top-k sampling
        'n':
          anyOf:
            - type: integer
            - type: 'null'
          title: 'N'
          description: Number of completions
          default: 1
        reasoning:
          anyOf:
            - $ref: '#/components/schemas/ReasoningFields'
            - type: 'null'
          description: Reasoning configuration for the model
        stream_options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Stream Options
          description: 'Options for streaming responses, e.g., {''include_usage'': true}'
      type: object
      required:
        - model
        - messages
      title: CreateCompletionRequest_chat_textv2
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatCompletionRequestMessage:
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
          title: Role
          description: >-
            The role of the messages author. One of `system`, `user`, or
            `assistant`.
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Content
          description: The contents of the message. `content` is required for all messages
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: >-
            The name of the author of this message. May contain a-z, A-Z, 0-9,
            and underscores, with a maximum length of 64 characters.
      type: object
      required:
        - role
        - content
      title: ChatCompletionRequestMessage
    ReasoningFields:
      properties:
        effort:
          anyOf:
            - type: string
              enum:
                - xhigh
                - high
                - medium
                - low
                - minimal
                - none
            - type: 'null'
          title: Effort
          description: Reasoning effort level (OpenAI-style)
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          description: Specific token limit for reasoning (Anthropic-style)
        exclude:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Exclude
          description: Set to true to exclude reasoning tokens from response
          default: false
        enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Enabled
          description: Enable reasoning with default parameters
      type: object
      title: ReasoningFields
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.