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

# Update stored chat completion metadata

> Replaces the metadata object stored with a chat completion.



## OpenAPI

````yaml /api-reference/chat.json post /v1/chat/completions/{completion_id}
openapi: 3.1.0
info:
  title: SynapsAI Chat API
  version: 1.0.0
servers:
  - url: https://api.synapsai.cloud
    description: Production server
security: []
paths:
  /v1/chat/completions/{completion_id}:
    post:
      summary: Update stored chat completion metadata
      description: Replaces the metadata object stored with a chat completion.
      operationId: updateChatCompletion
      parameters:
        - name: completion_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - metadata
              properties:
                metadata:
                  type: object
                  additionalProperties: true
      responses:
        '200':
          description: Updated chat completion
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionsResponse'
        '404':
          description: No stored chat completion with this id
components:
  schemas:
    ChatCompletionsResponse:
      type: object
      description: Response schema for the chat completions endpoint.
      properties:
        id:
          type: string
          description: Unique identifier for this chat completion.
        object:
          type: string
          default: chat.completion
          description: Type of the returned object; defaults to 'chat.completion'.
        created:
          type: integer
          description: Unix timestamp (seconds) of creation.
        model:
          type: string
          description: Model identifier used to generate the chat response.
        choices:
          type: array
          items:
            $ref: '#/components/schemas/ChatChoice'
          description: List of chat choices returned by the model.
        usage:
          $ref: '#/components/schemas/ChatUsage'
          description: Token usage details for the chat completion.
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
    ChatChoice:
      type: object
      description: A single choice in a chat completion response.
      properties:
        index:
          type: integer
          description: Index position of this chat choice.
        message:
          $ref: '#/components/schemas/ChoiceMessage'
          description: Message object produced for this choice.
        logprobs:
          $ref: '#/components/schemas/Logprobs'
          nullable: true
          description: Optional token logprob information for the choice message.
        finish_reason:
          type: string
          enum:
            - stop
            - length
            - tool_calls
          default: stop
          description: >-
            Why generation ended for this choice (e.g., 'stop', 'length',
            'tool_calls').
    ChatUsage:
      type: object
      description: Token usage counts for chat completions.
      properties:
        prompt_tokens:
          type: integer
          description: Number of tokens consumed by the input messages.
        completion_tokens:
          type: integer
          description: Number of tokens generated by the assistant in the response.
        total_tokens:
          type: integer
          description: Total tokens consumed for the chat request.
    ChoiceMessage:
      type: object
      description: Message shape returned inside a ChatChoice, can be plain or structured.
      properties:
        role:
          type: string
          description: Role associated with the choice message (e.g., 'assistant').
        content:
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties:
                  type: string
          nullable: true
          description: >-
            Content of the choice: either a single string or a list of small
            key/value parts. May be null when the model returns tool calls
            instead.
        tool_calls:
          type: array
          items:
            $ref: '#/components/schemas/ToolCall'
          nullable: true
          description: Tool calls parsed from the model response, when available.
    Logprobs:
      type: object
      description: Collection of token-level logprob entries for an output.
      properties:
        content:
          type: array
          items:
            $ref: '#/components/schemas/LogprobContent'
          description: List of per-token logprob data.
    ToolCall:
      type: object
      description: A tool call requested by the model in a chat completion response.
      properties:
        id:
          type: string
          description: Unique identifier for this tool call.
        type:
          type: string
          enum:
            - function
          default: function
          description: Type of tool call; currently always 'function'.
        function:
          $ref: '#/components/schemas/ToolCallFunction'
          description: The function to invoke and its arguments.
      required:
        - id
        - type
        - function
    LogprobContent:
      type: object
      description: A single token's log probability information.
      properties:
        token:
          type: string
          description: The token string.
        logprob:
          type: number
          description: Log probability for the token.
        top_logprobs:
          type: object
          additionalProperties: true
          nullable: true
          description: Optional mapping of top tokens to their logprobs for this position.
    ToolCallFunction:
      type: object
      description: Function invocation details inside a tool call.
      properties:
        name:
          type: string
          description: Name of the function the model wants to call.
        arguments:
          type: string
          description: JSON-encoded arguments for the function call.
      required:
        - name
        - arguments

````

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