{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trajectory/json-schema/trajectory-chat-completion-chunk-schema.json",
  "title": "ChatCompletionChunk",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trajectory-inference-api-openapi.yml#/components/schemas/ChatCompletionChunk",
  "additionalProperties": true,
  "properties": {
    "id": {
      "title": "Id",
      "type": "string"
    },
    "object": {
      "title": "Object",
      "type": "string"
    },
    "created": {
      "title": "Created",
      "type": "integer"
    },
    "model": {
      "title": "Model",
      "type": "string"
    },
    "choices": {
      "items": {
        "$ref": "#/$defs/ChatCompletionChunkChoice"
      },
      "title": "Choices",
      "type": "array"
    },
    "usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/Usage"
        },
        {
          "type": "null"
        }
      ]
    },
    "service_tier": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Service Tier"
    },
    "system_fingerprint": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "System Fingerprint"
    }
  },
  "required": [
    "id",
    "object",
    "created",
    "model",
    "choices"
  ],
  "type": "object",
  "$defs": {
    "ChatCompletionChoiceLogprobs": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ChatCompletionTokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ChatCompletionTokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Refusal"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "ChatCompletionChoiceLogprobs"
    },
    "ChatCompletionChunkChoice": {
      "additionalProperties": true,
      "properties": {
        "index": {
          "title": "Index",
          "type": "integer"
        },
        "delta": {
          "$ref": "#/$defs/ChatCompletionChunkDelta"
        },
        "finish_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Finish Reason"
        },
        "logprobs": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChatCompletionChoiceLogprobs"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "index",
        "delta"
      ],
      "title": "ChatCompletionChunkChoice",
      "type": "object"
    },
    "ChatCompletionChunkDelta": {
      "additionalProperties": true,
      "properties": {
        "role": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Role"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Refusal"
        },
        "function_call": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChatCompletionChunkFunction"
            },
            {
              "type": "null"
            }
          ]
        },
        "tool_calls": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ChatCompletionChunkToolCall"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tool Calls"
        }
      },
      "title": "ChatCompletionChunkDelta",
      "type": "object"
    },
    "ChatCompletionChunkFunction": {
      "additionalProperties": true,
      "properties": {
        "arguments": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Arguments"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        }
      },
      "title": "ChatCompletionChunkFunction",
      "type": "object"
    },
    "ChatCompletionChunkToolCall": {
      "additionalProperties": true,
      "properties": {
        "index": {
          "title": "Index",
          "type": "integer"
        },
        "id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Id"
        },
        "function": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChatCompletionChunkFunction"
            },
            {
              "type": "null"
            }
          ]
        },
        "type": {
          "anyOf": [
            {
              "const": "function",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Type"
        }
      },
      "required": [
        "index"
      ],
      "title": "ChatCompletionChunkToolCall",
      "type": "object"
    },
    "ChatCompletionTokenLogprob": {
      "properties": {
        "token": {
          "type": "string",
          "title": "Token"
        },
        "logprob": {
          "type": "number",
          "title": "Logprob"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Bytes"
        },
        "top_logprobs": {
          "items": {
            "$ref": "#/$defs/ChatCompletionTokenTopLogprob"
          },
          "type": "array",
          "title": "Top Logprobs"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "token",
        "logprob",
        "top_logprobs"
      ],
      "title": "ChatCompletionTokenLogprob"
    },
    "ChatCompletionTokenTopLogprob": {
      "properties": {
        "token": {
          "type": "string",
          "title": "Token"
        },
        "logprob": {
          "type": "number",
          "title": "Logprob"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Bytes"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "token",
        "logprob"
      ],
      "title": "ChatCompletionTokenTopLogprob"
    },
    "CompletionTokensDetails": {
      "properties": {
        "accepted_prediction_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Accepted Prediction Tokens"
        },
        "audio_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Audio Tokens"
        },
        "reasoning_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reasoning Tokens"
        },
        "rejected_prediction_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rejected Prediction Tokens"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "CompletionTokensDetails"
    },
    "PromptTokensDetails": {
      "properties": {
        "audio_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Audio Tokens"
        },
        "cached_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cached Tokens"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "PromptTokensDetails"
    },
    "Usage": {
      "properties": {
        "prompt_tokens": {
          "type": "integer",
          "title": "Prompt Tokens"
        },
        "completion_tokens": {
          "type": "integer",
          "title": "Completion Tokens"
        },
        "total_tokens": {
          "type": "integer",
          "title": "Total Tokens"
        },
        "completion_tokens_details": {
          "anyOf": [
            {
              "$ref": "#/$defs/CompletionTokensDetails"
            },
            {
              "type": "null"
            }
          ]
        },
        "prompt_tokens_details": {
          "anyOf": [
            {
              "$ref": "#/$defs/PromptTokensDetails"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "prompt_tokens",
        "completion_tokens",
        "total_tokens"
      ],
      "title": "Usage"
    }
  }
}