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

# Create a chat completion

> OpenAI's Chat Completions API. The model's plan arrives as `reasoning_content`, before the answer. With `stream: true` the answer arrives as `text/event-stream`. The stream ends with `data: [DONE]`.



## OpenAPI

````yaml /platform/openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: Notra Labs Platform API
  version: 1.0.0
  description: >-
    OpenAI-compatible API for writer-0.1. Requests may have up to 500 messages
    and 1.45 MB of JSON. Docs: https://www.usenotra.com/docs/platform/overview.
    For agents: https://platform.usenotra.com/llms.txt.
servers:
  - url: https://platform.usenotra.com
security:
  - bearerAuth: []
tags:
  - name: Chat Completions
  - name: Responses
  - name: Models
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions
      summary: Create a chat completion
      description: >-
        OpenAI's Chat Completions API. The model's plan arrives as
        `reasoning_content`, before the answer. With `stream: true` the answer
        arrives as `text/event-stream`. The stream ends with `data: [DONE]`.
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            example:
              model: writer-0.1
              messages:
                - role: user
                  content: Write a changelog entry for faster search.
      responses:
        '200':
          description: The answer, or a stream of chunks.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatCompletionChunk'
        '400':
          description: >-
            `invalid_request`, `unsupported_parameter`,
            `context_length_exceeded`, `upstream_error`
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Fix the request; `param` names the field.
                  type: invalid_request_error
                  param: null
                  code: invalid_request
        '401':
          description: '`invalid_api_key`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Check the key and the Authorization header.
                  type: invalid_request_error
                  param: null
                  code: invalid_api_key
        '402':
          description: '`insufficient_credits`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: >-
                    Add credits in the console, or lower the maximum answer
                    length.
                  type: invalid_request_error
                  param: null
                  code: insufficient_credits
        '404':
          description: '`model_not_found`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Use a model from `GET /v1/models`.
                  type: invalid_request_error
                  param: null
                  code: model_not_found
        '405':
          description: '`method_not_allowed`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Use POST for generation and GET for models.
                  type: invalid_request_error
                  param: null
                  code: method_not_allowed
        '413':
          description: '`request_too_large`, `upstream_error`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Send at most 1.45 MB of JSON.
                  type: invalid_request_error
                  param: null
                  code: request_too_large
        '422':
          description: '`upstream_error`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: >-
                    At 400, 413 or 422 the model backend rejected the request:
                    fix it. At 502, retry with exponential backoff.
                  type: invalid_request_error
                  param: null
                  code: upstream_error
        '429':
          description: '`rate_limit_exceeded`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: >-
                    Wait for `retry-after` seconds; the `x-ratelimit-*` headers
                    show the limits.
                  type: invalid_request_error
                  param: null
                  code: rate_limit_exceeded
        '502':
          description: '`upstream_error`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: >-
                    At 400, 413 or 422 the model backend rejected the request:
                    fix it. At 502, retry with exponential backoff.
                  type: server_error
                  param: null
                  code: upstream_error
        '503':
          description: >-
            `model_starting`, `model_overloaded`, `model_unavailable`,
            `service_unavailable`
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Retry after `retry-after` seconds for up to 10 minutes.
                  type: server_error
                  param: null
                  code: model_starting
        '504':
          description: '`upstream_timeout`'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  message: Retry with exponential backoff, or stream the answer.
                  type: server_error
                  param: null
                  code: upstream_timeout
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      x-notra-rejected-parameters:
        - logprobs
        - top_logprobs
        - logit_bias
        - audio
        - modalities
        - prediction
      description: >-
        Parameters not listed here are ignored. `logprobs`, `top_logprobs`,
        `logit_bias`, `audio`, `modalities`, `prediction` and a legacy
        `function_call` that names a function are rejected with 400
        `unsupported_parameter`.
      properties:
        model:
          type: string
          enum:
            - writer-0.1
        messages:
          type: array
          minItems: 1
          maxItems: 500
          items:
            $ref: '#/components/schemas/ChatMessage'
        stream:
          type: boolean
          default: false
          description: Stream the answer as server-sent events.
        stream_options:
          type: object
          properties:
            include_usage:
              type: boolean
              description: Send usage in a last chunk with empty `choices`.
        max_tokens:
          type: integer
          minimum: 1
          description: >-
            Caps the output, plan included. Without `max_tokens` the model can
            write up to 32768 tokens. Larger values are lowered to 32768 and to
            the room left in the 262144-token context window.
        max_completion_tokens:
          type: integer
          minimum: 1
          description: >-
            Caps the output, plan included. Without `max_completion_tokens` the
            model can write up to 32768 tokens. Larger values are lowered to
            32768 and to the room left in the 262144-token context window.
        stop:
          anyOf:
            - type: string
            - type: array
              items:
                type: string
              maxItems: 4
          description: >-
            Ends the answer before the first match. Applies to the answer, never
            to the plan, and never cuts tool calls.
        response_format:
          $ref: '#/components/schemas/ResponseFormat'
        tools:
          type: array
          items:
            $ref: '#/components/schemas/ChatTool'
          description: Function tools. Other tool types are ignored.
        tool_choice:
          anyOf:
            - type: string
              enum:
                - auto
                - none
                - required
            - type: object
              required:
                - type
                - function
              properties:
                type:
                  type: string
                  const: function
                function:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
        parallel_tool_calls:
          type: boolean
        temperature:
          type: number
          minimum: 0
          maximum: 2
          description: >-
            Accepted and range-checked, but writer-0.1 samples with its own
            fixed settings, so it doesn't change the answer.
        top_p:
          type: number
          minimum: 0
          maximum: 1
          description: >-
            Accepted and range-checked, but writer-0.1 samples with its own
            fixed settings, so it doesn't change the answer.
        presence_penalty:
          type: number
          minimum: -2
          maximum: 2
          description: Passed to the model.
        frequency_penalty:
          type: number
          minimum: -2
          maximum: 2
          description: Passed to the model.
        seed:
          type: integer
          description: Passed to the model.
        user:
          type: string
          description: Passed to the model.
        'n':
          type: integer
          const: 1
          description: Must be 1.
    ChatCompletion:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
          examples:
            - chatcmpl-abc123
        object:
          type: string
          const: chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            required:
              - index
              - message
              - finish_reason
            properties:
              index:
                type: integer
              message:
                type: object
                required:
                  - role
                  - content
                properties:
                  role:
                    type: string
                    const: assistant
                  content:
                    anyOf:
                      - type: string
                      - type: 'null'
                  reasoning_content:
                    anyOf:
                      - type: string
                        description: The plan the model wrote before its answer.
                      - type: 'null'
                  tool_calls:
                    type: array
                    items:
                      $ref: '#/components/schemas/ToolCall'
              logprobs:
                type: 'null'
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - tool_calls
        usage:
          $ref: '#/components/schemas/Usage'
    ChatCompletionChunk:
      type: object
      description: 'One server-sent event. The stream ends with `data: [DONE]`.'
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
        object:
          type: string
          const: chat.completion.chunk
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              delta:
                type: object
                properties:
                  role:
                    type: string
                  content:
                    type: string
                  reasoning_content:
                    type: string
                  tool_calls:
                    type: array
                    items:
                      type: object
              logprobs:
                type: 'null'
              finish_reason:
                anyOf:
                  - type: string
                  - type: 'null'
        usage:
          anyOf:
            - $ref: '#/components/schemas/Usage'
            - type: 'null'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
            - param
            - code
          properties:
            message:
              type: string
            type:
              type: string
              description: >-
                OpenAI's error type, such as `invalid_request_error`,
                `authentication_error`, `insufficient_quota`, `requests`,
                `tokens` or `server_error`.
            param:
              anyOf:
                - type: string
                  description: The request field that caused the error.
                - type: 'null'
            code:
              type: string
              enum:
                - invalid_request
                - unsupported_parameter
                - context_length_exceeded
                - invalid_api_key
                - insufficient_credits
                - model_not_found
                - method_not_allowed
                - request_too_large
                - rate_limit_exceeded
                - upstream_error
                - upstream_timeout
                - model_starting
                - model_overloaded
                - model_unavailable
                - service_unavailable
    ChatMessage:
      anyOf:
        - title: System, developer or user message
          type: object
          required:
            - role
            - content
          properties:
            role:
              type: string
              enum:
                - system
                - developer
                - user
            content:
              $ref: '#/components/schemas/ChatContent'
        - title: Assistant message
          type: object
          required:
            - role
            - content
          properties:
            role:
              type: string
              const: assistant
            content:
              $ref: '#/components/schemas/ChatContent'
        - title: Assistant message with tool calls
          type: object
          required:
            - role
            - tool_calls
          properties:
            role:
              type: string
              const: assistant
            content:
              anyOf:
                - $ref: '#/components/schemas/ChatContent'
                - type: 'null'
            tool_calls:
              type: array
              minItems: 1
              items:
                $ref: '#/components/schemas/ToolCall'
        - title: Tool result
          type: object
          required:
            - role
          properties:
            role:
              type: string
              const: tool
            content:
              anyOf:
                - $ref: '#/components/schemas/ChatContent'
                - type: 'null'
            tool_call_id:
              type: string
              description: The call this result answers.
    ResponseFormat:
      anyOf:
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              const: text
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              const: json_object
        - title: JSON Schema
          type: object
          required:
            - type
            - json_schema
          properties:
            type:
              type: string
              const: json_schema
            json_schema:
              type: object
              required:
                - name
                - schema
              properties:
                name:
                  type: string
                  pattern: ^[a-zA-Z0-9_-]{1,64}$
                schema:
                  type: object
                  additionalProperties: true
                strict:
                  type: boolean
                description:
                  type: string
    ChatTool:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          const: function
        function:
          type: object
          required:
            - name
          properties:
            name:
              type: string
              pattern: ^[a-zA-Z0-9_-]{1,64}$
            description:
              type: string
            parameters:
              type: object
              description: A JSON Schema object for the function's arguments.
              additionalProperties: true
            strict:
              type: boolean
    ToolCall:
      type: object
      required:
        - id
        - type
        - function
      properties:
        id:
          type: string
        type:
          type: string
          const: function
        function:
          type: object
          required:
            - name
            - arguments
          properties:
            name:
              type: string
            arguments:
              type: string
              description: The arguments as a JSON string.
    Usage:
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
          description: Output tokens, plan included.
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
        completion_tokens_details:
          type: object
          properties:
            reasoning_tokens:
              type: integer
              description: The plan's share of the output tokens.
    ChatContent:
      anyOf:
        - type: string
        - type: array
          items:
            $ref: '#/components/schemas/TextPart'
      description: 'Text only: a string or a list of text parts.'
    TextPart:
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          const: text
        text:
          type: string
  headers:
    RequestId:
      description: The request's ID. Include it when you contact support.
      schema:
        type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An API key from the console, starting with `nl_live_` or `nl_test_`.

````

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