# Chat

Chat completion endpoints (OpenAI-compatible).

## List chat completions

> List chat completions captured in telemetry, scoped to the authenticated project.

```json
{"openapi":"3.1.0","info":{"title":"Maniac Inference Gateway API","version":"1.0.0"},"tags":[{"name":"Chat","description":"Chat completion endpoints (OpenAI-compatible)."}],"servers":[{"url":"https://platform.maniac.ai","description":"The Maniac API"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"API key in Authorization header using Bearer <token>."}},"schemas":{"ChatListRes":{"properties":{"object":{"type":"string","const":"list","title":"Object","description":"Object type identifier.","default":"list"},"data":{"items":{"$ref":"#/components/schemas/ChatResRelaxed-Output"},"type":"array","title":"Data","description":"Returned items."},"total":{"type":"integer","minimum":0,"title":"Total","description":"Total number of items available for this resource."}},"additionalProperties":false,"type":"object","required":["data","total"],"title":"ChatListRes","description":"OpenAI-style list response for chat completions."},"ChatResRelaxed-Output":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Completion id."},"choices":{"items":{"$ref":"#/components/schemas/RegisterOutputChoice"},"type":"array","title":"Choices"},"created":{"anyOf":[{},{"type":"null"}],"title":"Created","description":"Creation timestamp (unix seconds)."},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model","description":"Model slug used."},"object":{"type":"string","const":"chat.completion","title":"Object","description":"Object type.","default":"chat.completion"},"usage":{"anyOf":[{"$ref":"#/components/schemas/ChatResponseUsage"},{"type":"null"}],"description":"Token usage."},"provider":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider","description":"Upstream provider name, if available."},"container":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Container","description":"Container label used for routing, if any."},"model_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model Id","description":"Model ID (uuid)."},"spend":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Spend","description":"Estimated spend."},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Tags for this completion."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Metadata for this completion."},"trace":{"anyOf":[{"$ref":"#/components/schemas/TraceContext"},{"type":"null"}],"description":"Optional external trace/span context associated with this completion."}},"type":"object","required":["choices"],"title":"ChatResRelaxed"},"RegisterOutputChoice":{"properties":{"index":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Index","description":"Choice index."},"message":{"$ref":"#/components/schemas/RegisterOutputMessage"},"finish_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Finish Reason","description":"Reason the generation finished."}},"additionalProperties":true,"type":"object","required":["message"],"title":"RegisterOutputChoice"},"RegisterOutputMessage":{"properties":{"role":{"type":"string","title":"Role","description":"Message role (system, user, assistant)."},"content":{"anyOf":[{"type":"string"},{"items":{},"type":"array"},{"type":"null"}],"title":"Content","description":"Message content (string or structured parts)."}},"additionalProperties":true,"type":"object","required":["role"],"title":"RegisterOutputMessage"},"ChatResponseUsage":{"properties":{"prompt_tokens":{"type":"number","title":"Prompt Tokens","description":"Prompt tokens."},"completion_tokens":{"type":"number","title":"Completion Tokens","description":"Completion tokens."},"total_tokens":{"type":"number","title":"Total Tokens","description":"Total tokens."},"completion_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Completion Tokens Details"},"prompt_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Prompt Tokens Details"}},"additionalProperties":true,"type":"object","required":["prompt_tokens","completion_tokens","total_tokens"],"title":"ChatResponseUsage","description":"Token usage in a chat completion response."},"TraceContext":{"properties":{"id":{"type":"string","title":"Id","description":"External trace identifier used to group requests."},"span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Span Id","description":"Optional span identifier within the trace."},"parent_span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Span Id","description":"Optional parent span identifier."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional trace name."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source","description":"Optional trace source, e.g. langchain."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Optional metadata associated with the trace."}},"additionalProperties":false,"type":"object","required":["id"],"title":"TraceContext"},"ErrorResponse":{"properties":{"error":{"$ref":"#/components/schemas/ManiacError","description":"Error payload."}},"additionalProperties":false,"type":"object","required":["error"],"title":"ErrorResponse","description":"Response body for errors."},"ManiacError":{"properties":{"code":{"type":"string","title":"Code","description":"Machine-readable error code."},"message":{"type":"string","title":"Message","description":"Human-readable error message."},"details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Details","description":"Additional error details."}},"additionalProperties":false,"type":"object","required":["code","message"],"title":"ManiacError","description":"Standard Maniac API error envelope.\n\nThis matches the shape already used by v2 auth (`detail={\"error\": {...}}`)."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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"}}},"paths":{"/v1/chat/completions":{"get":{"tags":["Chat"],"summary":"List chat completions","description":"List chat completions captured in telemetry, scoped to the authenticated project.","operationId":"chat_completions_list","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"model","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model"}},{"name":"container","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Container"}},{"name":"order","in":"query","required":false,"schema":{"enum":["asc","desc"],"type":"string","default":"desc","title":"Order"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"type":"object","additionalProperties":true},{"type":"null"}],"title":"Metadata"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatListRes"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Too Many Requests","headers":{"X-RateLimit-Limit":{"description":"Request limit per window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in current window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp when the rate limit resets.","schema":{"type":"integer"}},"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Not Implemented","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Upstream Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Create a chat completion

> Create a chat completion using the specified model.\
> \
> Supports both streaming and non-streaming responses and is compatible with\
> OpenAI's chat completions API. Use a container slug (\`maniac:\<container>\`)\
> or an external slug (e.g. \`openai/gpt-4o\`). \`/\` and \`:\` are treated\
> equivalently on input.

```json
{"openapi":"3.1.0","info":{"title":"Maniac Inference Gateway API","version":"1.0.0"},"tags":[{"name":"Chat","description":"Chat completion endpoints (OpenAI-compatible)."}],"servers":[{"url":"https://platform.maniac.ai","description":"The Maniac API"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"API key in Authorization header using Bearer <token>."}},"schemas":{"ChatReq":{"properties":{"messages":{"items":{"$ref":"#/components/schemas/Message"},"type":"array","title":"Messages","description":"Conversation messages."},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model","description":"Model slug to use. Supports global slugs and container routes; `/` and `:` are treated equivalently on input."},"models":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Models","description":"Fallback models."},"frequency_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Frequency Penalty","description":"Frequency penalty."},"logit_bias":{"anyOf":[{"additionalProperties":{"type":"number"},"type":"object"},{"type":"null"}],"title":"Logit Bias","description":"Logit bias."},"logprobs":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Logprobs","description":"Include logprobs."},"top_logprobs":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Top Logprobs","description":"Top logprobs."},"max_completion_tokens":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Max Completion Tokens","description":"Max completion tokens."},"max_tokens":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Max Tokens","description":"Max tokens."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Arbitrary key/value metadata to attach to the request."},"presence_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Presence Penalty","description":"Presence penalty."},"reasoning":{"anyOf":[{"$ref":"#/components/schemas/ReasoningConfig"},{"type":"null"}],"description":"Reasoning config."},"response_format":{"anyOf":[{"$ref":"#/components/schemas/ResponseFormatText"},{"$ref":"#/components/schemas/ResponseFormatJsonSchema"},{"$ref":"#/components/schemas/ResponseFormatJsonObject"},{"type":"null"}],"title":"Response Format","description":"Response format."},"seed":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Seed","description":"Random seed."},"stop":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Stop","description":"Stop sequences."},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Stream","description":"Stream response.","default":false},"stream_options":{"anyOf":[{"$ref":"#/components/schemas/StreamOptions"},{"type":"null"}],"description":"Stream options."},"temperature":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Temperature","description":"Temperature."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"]},{"$ref":"#/components/schemas/ToolChoiceFunction"},{"type":"null"}],"title":"Tool Choice","description":"Tool choice."},"tools":{"anyOf":[{"items":{"$ref":"#/components/schemas/ToolDefinition"},"type":"array"},{"type":"null"}],"title":"Tools","description":"Tools."},"parallel_tool_calls":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Parallel Tool Calls","description":"Whether the model may emit multiple tool calls in parallel."},"top_p":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Top P","description":"Top p."},"tags":{"items":{"type":"string"},"type":"array","title":"Tags","description":"Optional tags for tracking."},"store":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Store","description":"Whether to store the completion in the database.","default":true},"trace":{"anyOf":[{"$ref":"#/components/schemas/TraceContext"},{"type":"null"}],"description":"Optional external trace/span context used to group related requests across containers."}},"additionalProperties":false,"type":"object","required":["messages"],"title":"ManiacChatRequest","description":"OpenAI-compatible chat completion request with Maniac extensions."},"Message":{"properties":{"role":{"type":"string","enum":["system","user","assistant","developer","tool"],"title":"Role","description":"Message role."},"content":{"anyOf":[{"type":"string"},{"items":{"anyOf":[{"$ref":"#/components/schemas/TextContentPart"},{"$ref":"#/components/schemas/ImageContentPart"}]},"type":"array"},{"type":"null"}],"title":"Content","description":"Message content (string or list of content parts)."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional name."},"tool_calls":{"anyOf":[{"items":{"$ref":"#/components/schemas/ToolCall"},"type":"array"},{"type":"null"}],"title":"Tool Calls","description":"Tool calls (assistant message)."},"tool_call_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tool Call Id","description":"Tool call ID (tool messages)."}},"additionalProperties":false,"type":"object","required":["role"],"title":"Message","description":"OpenAI-style chat message."},"TextContentPart":{"properties":{"type":{"type":"string","const":"text","title":"Type","description":"Content part type.","default":"text"},"text":{"type":"string","title":"Text","description":"Text content."}},"type":"object","required":["text"],"title":"TextContentPart","description":"Text content part in a message."},"ImageContentPart":{"properties":{"type":{"type":"string","const":"image_url","title":"Type","description":"Content part type.","default":"image_url"},"image_url":{"additionalProperties":true,"type":"object","title":"Image Url","description":"Image URL object with 'url' and optional 'detail'."}},"type":"object","required":["image_url"],"title":"ImageContentPart","description":"Image content part in a message."},"ToolCall":{"properties":{"id":{"type":"string","title":"Id","description":"Tool call id."},"type":{"type":"string","const":"function","title":"Type","description":"Tool call type.","default":"function"},"function":{"$ref":"#/components/schemas/FunctionCall","description":"Function call details."}},"type":"object","required":["id","function"],"title":"ToolCall","description":"A tool call emitted by the model."},"FunctionCall":{"properties":{"name":{"type":"string","title":"Name","description":"Function name."},"arguments":{"type":"string","title":"Arguments","description":"JSON-encoded arguments."}},"type":"object","required":["name","arguments"],"title":"FunctionCall","description":"Function call payload inside a tool call."},"ReasoningConfig":{"properties":{"effort":{"title":"Effort","description":"Reasoning effort level.","type":"string","enum":["none","minimal","low","medium","high","xhigh"],"nullable":true},"summary":{"title":"Summary","description":"Reasoning summary verbosity.","type":"string","enum":["auto","concise","detailed"],"nullable":true}},"type":"object","title":"ReasoningConfig","description":"Reasoning configuration for reasoning models."},"ResponseFormatText":{"properties":{"type":{"type":"string","const":"text","title":"Type","description":"Format type.","default":"text"}},"type":"object","title":"ResponseFormatText","description":"Plain text response format (default)."},"ResponseFormatJsonSchema":{"properties":{"type":{"type":"string","const":"json_schema","title":"Type","description":"Format type.","default":"json_schema"},"json_schema":{"$ref":"#/components/schemas/JsonSchemaConfig","description":"JSON schema configuration."}},"type":"object","required":["json_schema"],"title":"ResponseFormatJsonSchema","description":"Structured JSON output via a supplied schema."},"JsonSchemaConfig":{"properties":{"name":{"type":"string","title":"Name","description":"Schema name."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Schema description."},"schema":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Schema","description":"JSON Schema object."},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Strict","description":"Whether to enforce strict schema adherence."}},"type":"object","required":["name"],"title":"JsonSchemaConfig","description":"Configuration for json_schema response format."},"ResponseFormatJsonObject":{"properties":{"type":{"type":"string","const":"json_object","title":"Type","description":"Format type.","default":"json_object"}},"type":"object","title":"ResponseFormatJsonObject","description":"JSON object response format (legacy JSON mode)."},"StreamOptions":{"properties":{"include_usage":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Include Usage","description":"Include a final chunk with token usage statistics."}},"type":"object","title":"StreamOptions","description":"Options for streaming responses."},"ToolChoiceFunction":{"properties":{"type":{"type":"string","const":"function","title":"Type","description":"Tool choice type.","default":"function"},"function":{"$ref":"#/components/schemas/ToolChoiceFunctionName","description":"Function to call."}},"type":"object","required":["function"],"title":"ToolChoiceFunction","description":"Force the model to call a specific function."},"ToolChoiceFunctionName":{"properties":{"name":{"type":"string","title":"Name","description":"Function name."}},"type":"object","required":["name"],"title":"ToolChoiceFunctionName","description":"Specifies a function name to force-call."},"ToolDefinition":{"properties":{"type":{"type":"string","const":"function","title":"Type","description":"Tool type.","default":"function"},"function":{"$ref":"#/components/schemas/FunctionDefinition","description":"Function definition."}},"type":"object","required":["function"],"title":"ToolDefinition","description":"A tool the model may call."},"FunctionDefinition":{"properties":{"name":{"type":"string","title":"Name","description":"Function name."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Description of what the function does."},"parameters":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Parameters","description":"JSON Schema for the function parameters."},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Strict","description":"Whether to enforce strict schema adherence."}},"type":"object","required":["name"],"title":"FunctionDefinition","description":"Function definition inside a tool."},"TraceContext":{"properties":{"id":{"type":"string","title":"Id","description":"External trace identifier used to group requests."},"span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Span Id","description":"Optional span identifier within the trace."},"parent_span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Span Id","description":"Optional parent span identifier."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional trace name."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source","description":"Optional trace source, e.g. langchain."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Optional metadata associated with the trace."}},"additionalProperties":false,"type":"object","required":["id"],"title":"TraceContext"},"ChatRes":{"properties":{"id":{"type":"string","title":"Id","description":"Completion id."},"choices":{"items":{"$ref":"#/components/schemas/ChatResponseChoice-Output"},"type":"array","title":"Choices","description":"Response choices."},"created":{"type":"number","title":"Created","description":"Creation timestamp (unix)."},"model":{"type":"string","title":"Model","description":"Model used."},"object":{"type":"string","const":"chat.completion","title":"Object","description":"Object type.","default":"chat.completion"},"usage":{"anyOf":[{"$ref":"#/components/schemas/ChatResponseUsage"},{"type":"null"}],"description":"Token usage."},"provider":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider","description":"Upstream provider name, if available."},"container":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Container","description":"Container label used for routing, if any."}},"additionalProperties":false,"type":"object","required":["id","choices","created","model"],"title":"ChatRes"},"ChatResponseChoice-Output":{"properties":{"index":{"type":"number","title":"Index","description":"Choice index."},"message":{"$ref":"#/components/schemas/ChatResponseMessage-Output","description":"Assistant message."},"finish_reason":{"title":"Finish Reason","description":"Reason generation finished.","type":"string","enum":["stop","length","tool_calls","content_filter","error"],"nullable":true},"logprobs":{"anyOf":[{},{"type":"null"}],"title":"Logprobs","description":"Logprobs if requested."}},"additionalProperties":false,"type":"object","required":["index","message"],"title":"ChatResponseChoice","description":"Single choice in a chat completion response."},"ChatResponseMessage-Output":{"properties":{"role":{"type":"string","title":"Role","description":"Message role."},"content":{"anyOf":[{},{"type":"null"}],"title":"Content","description":"Message content."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional name."},"tool_calls":{"anyOf":[{"items":{"$ref":"#/components/schemas/ToolCall"},"type":"array"},{"type":"null"}],"title":"Tool Calls","description":"Tool calls."}},"additionalProperties":true,"type":"object","required":["role"],"title":"ChatResponseMessage","description":"Assistant message in a choice."},"ChatResponseUsage":{"properties":{"prompt_tokens":{"type":"number","title":"Prompt Tokens","description":"Prompt tokens."},"completion_tokens":{"type":"number","title":"Completion Tokens","description":"Completion tokens."},"total_tokens":{"type":"number","title":"Total Tokens","description":"Total tokens."},"completion_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Completion Tokens Details"},"prompt_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Prompt Tokens Details"}},"additionalProperties":true,"type":"object","required":["prompt_tokens","completion_tokens","total_tokens"],"title":"ChatResponseUsage","description":"Token usage in a chat completion response."},"ErrorResponse":{"properties":{"error":{"$ref":"#/components/schemas/ManiacError","description":"Error payload."}},"additionalProperties":false,"type":"object","required":["error"],"title":"ErrorResponse","description":"Response body for errors."},"ManiacError":{"properties":{"code":{"type":"string","title":"Code","description":"Machine-readable error code."},"message":{"type":"string","title":"Message","description":"Human-readable error message."},"details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Details","description":"Additional error details."}},"additionalProperties":false,"type":"object","required":["code","message"],"title":"ManiacError","description":"Standard Maniac API error envelope.\n\nThis matches the shape already used by v2 auth (`detail={\"error\": {...}}`)."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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"}}},"paths":{"/v1/chat/completions":{"post":{"tags":["Chat"],"summary":"Create a chat completion","description":"Create a chat completion using the specified model.\n\nSupports both streaming and non-streaming responses and is compatible with\nOpenAI's chat completions API. Use a container slug (`maniac:<container>`)\nor an external slug (e.g. `openai/gpt-4o`). `/` and `:` are treated\nequivalently on input.","operationId":"chat_completions_create","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatReq"}}}},"responses":{"200":{"description":"Server-Sent Events stream for streaming responses.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRes"}},"text/event-stream":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Too Many Requests","headers":{"X-RateLimit-Limit":{"description":"Request limit per window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in current window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp when the rate limit resets.","schema":{"type":"integer"}},"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Not Implemented","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Upstream Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Get a chat completion

> Fetch a single chat completion by id within the authenticated project.

```json
{"openapi":"3.1.0","info":{"title":"Maniac Inference Gateway API","version":"1.0.0"},"tags":[{"name":"Chat","description":"Chat completion endpoints (OpenAI-compatible)."}],"servers":[{"url":"https://platform.maniac.ai","description":"The Maniac API"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"API key in Authorization header using Bearer <token>."}},"schemas":{"ChatResRelaxed-Output":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Completion id."},"choices":{"items":{"$ref":"#/components/schemas/RegisterOutputChoice"},"type":"array","title":"Choices"},"created":{"anyOf":[{},{"type":"null"}],"title":"Created","description":"Creation timestamp (unix seconds)."},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model","description":"Model slug used."},"object":{"type":"string","const":"chat.completion","title":"Object","description":"Object type.","default":"chat.completion"},"usage":{"anyOf":[{"$ref":"#/components/schemas/ChatResponseUsage"},{"type":"null"}],"description":"Token usage."},"provider":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider","description":"Upstream provider name, if available."},"container":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Container","description":"Container label used for routing, if any."},"model_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model Id","description":"Model ID (uuid)."},"spend":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Spend","description":"Estimated spend."},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Tags for this completion."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Metadata for this completion."},"trace":{"anyOf":[{"$ref":"#/components/schemas/TraceContext"},{"type":"null"}],"description":"Optional external trace/span context associated with this completion."}},"type":"object","required":["choices"],"title":"ChatResRelaxed"},"RegisterOutputChoice":{"properties":{"index":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Index","description":"Choice index."},"message":{"$ref":"#/components/schemas/RegisterOutputMessage"},"finish_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Finish Reason","description":"Reason the generation finished."}},"additionalProperties":true,"type":"object","required":["message"],"title":"RegisterOutputChoice"},"RegisterOutputMessage":{"properties":{"role":{"type":"string","title":"Role","description":"Message role (system, user, assistant)."},"content":{"anyOf":[{"type":"string"},{"items":{},"type":"array"},{"type":"null"}],"title":"Content","description":"Message content (string or structured parts)."}},"additionalProperties":true,"type":"object","required":["role"],"title":"RegisterOutputMessage"},"ChatResponseUsage":{"properties":{"prompt_tokens":{"type":"number","title":"Prompt Tokens","description":"Prompt tokens."},"completion_tokens":{"type":"number","title":"Completion Tokens","description":"Completion tokens."},"total_tokens":{"type":"number","title":"Total Tokens","description":"Total tokens."},"completion_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Completion Tokens Details"},"prompt_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Prompt Tokens Details"}},"additionalProperties":true,"type":"object","required":["prompt_tokens","completion_tokens","total_tokens"],"title":"ChatResponseUsage","description":"Token usage in a chat completion response."},"TraceContext":{"properties":{"id":{"type":"string","title":"Id","description":"External trace identifier used to group requests."},"span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Span Id","description":"Optional span identifier within the trace."},"parent_span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Span Id","description":"Optional parent span identifier."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional trace name."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source","description":"Optional trace source, e.g. langchain."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Optional metadata associated with the trace."}},"additionalProperties":false,"type":"object","required":["id"],"title":"TraceContext"},"ErrorResponse":{"properties":{"error":{"$ref":"#/components/schemas/ManiacError","description":"Error payload."}},"additionalProperties":false,"type":"object","required":["error"],"title":"ErrorResponse","description":"Response body for errors."},"ManiacError":{"properties":{"code":{"type":"string","title":"Code","description":"Machine-readable error code."},"message":{"type":"string","title":"Message","description":"Human-readable error message."},"details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Details","description":"Additional error details."}},"additionalProperties":false,"type":"object","required":["code","message"],"title":"ManiacError","description":"Standard Maniac API error envelope.\n\nThis matches the shape already used by v2 auth (`detail={\"error\": {...}}`)."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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"}}},"paths":{"/v1/chat/completions/{completion_id}":{"get":{"tags":["Chat"],"summary":"Get a chat completion","description":"Fetch a single chat completion by id within the authenticated project.","operationId":"chat_completions_retrieve","parameters":[{"name":"completion_id","in":"path","required":true,"schema":{"type":"string","title":"Completion Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResRelaxed-Output"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Too Many Requests","headers":{"X-RateLimit-Limit":{"description":"Request limit per window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in current window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp when the rate limit resets.","schema":{"type":"integer"}},"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Not Implemented","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Upstream Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## Register chat completion examples

> Register completed chat examples for evaluation and analytics.\
> \
> This endpoint accepts input/output pairs and stores them for later analysis,\
> while aggregating usage metrics for reporting.

```json
{"openapi":"3.1.0","info":{"title":"Maniac Inference Gateway API","version":"1.0.0"},"tags":[{"name":"Chat","description":"Chat completion endpoints (OpenAI-compatible)."}],"servers":[{"url":"https://platform.maniac.ai","description":"The Maniac API"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"API key in Authorization header using Bearer <token>."}},"schemas":{"RegisterReq":{"properties":{"items":{"items":{"$ref":"#/components/schemas/Item"},"type":"array","title":"Items","description":"List of chat input/output examples."},"container":{"type":"string","title":"Container","description":"Container label to associate these examples with."}},"additionalProperties":false,"type":"object","required":["items","container"],"title":"RegisterChatCompletionsRequest","description":"Register completed chat examples for evaluation or analytics."},"Item":{"properties":{"input":{"$ref":"#/components/schemas/ChatReq"},"output":{"anyOf":[{"$ref":"#/components/schemas/ChatResRelaxed-Input"},{"type":"null"}],"description":"Chat completion output. Omit to register input-only examples."},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Optional tags for this example."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Optional metadata for this example."}},"additionalProperties":false,"type":"object","required":["input"],"title":"Item"},"ChatReq":{"properties":{"messages":{"items":{"$ref":"#/components/schemas/Message"},"type":"array","title":"Messages","description":"Conversation messages."},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model","description":"Model slug to use. Supports global slugs and container routes; `/` and `:` are treated equivalently on input."},"models":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Models","description":"Fallback models."},"frequency_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Frequency Penalty","description":"Frequency penalty."},"logit_bias":{"anyOf":[{"additionalProperties":{"type":"number"},"type":"object"},{"type":"null"}],"title":"Logit Bias","description":"Logit bias."},"logprobs":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Logprobs","description":"Include logprobs."},"top_logprobs":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Top Logprobs","description":"Top logprobs."},"max_completion_tokens":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Max Completion Tokens","description":"Max completion tokens."},"max_tokens":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Max Tokens","description":"Max tokens."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Arbitrary key/value metadata to attach to the request."},"presence_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Presence Penalty","description":"Presence penalty."},"reasoning":{"anyOf":[{"$ref":"#/components/schemas/ReasoningConfig"},{"type":"null"}],"description":"Reasoning config."},"response_format":{"anyOf":[{"$ref":"#/components/schemas/ResponseFormatText"},{"$ref":"#/components/schemas/ResponseFormatJsonSchema"},{"$ref":"#/components/schemas/ResponseFormatJsonObject"},{"type":"null"}],"title":"Response Format","description":"Response format."},"seed":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Seed","description":"Random seed."},"stop":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Stop","description":"Stop sequences."},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Stream","description":"Stream response.","default":false},"stream_options":{"anyOf":[{"$ref":"#/components/schemas/StreamOptions"},{"type":"null"}],"description":"Stream options."},"temperature":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Temperature","description":"Temperature."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"]},{"$ref":"#/components/schemas/ToolChoiceFunction"},{"type":"null"}],"title":"Tool Choice","description":"Tool choice."},"tools":{"anyOf":[{"items":{"$ref":"#/components/schemas/ToolDefinition"},"type":"array"},{"type":"null"}],"title":"Tools","description":"Tools."},"parallel_tool_calls":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Parallel Tool Calls","description":"Whether the model may emit multiple tool calls in parallel."},"top_p":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Top P","description":"Top p."},"tags":{"items":{"type":"string"},"type":"array","title":"Tags","description":"Optional tags for tracking."},"store":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Store","description":"Whether to store the completion in the database.","default":true},"trace":{"anyOf":[{"$ref":"#/components/schemas/TraceContext"},{"type":"null"}],"description":"Optional external trace/span context used to group related requests across containers."}},"additionalProperties":false,"type":"object","required":["messages"],"title":"ManiacChatRequest","description":"OpenAI-compatible chat completion request with Maniac extensions."},"Message":{"properties":{"role":{"type":"string","enum":["system","user","assistant","developer","tool"],"title":"Role","description":"Message role."},"content":{"anyOf":[{"type":"string"},{"items":{"anyOf":[{"$ref":"#/components/schemas/TextContentPart"},{"$ref":"#/components/schemas/ImageContentPart"}]},"type":"array"},{"type":"null"}],"title":"Content","description":"Message content (string or list of content parts)."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional name."},"tool_calls":{"anyOf":[{"items":{"$ref":"#/components/schemas/ToolCall"},"type":"array"},{"type":"null"}],"title":"Tool Calls","description":"Tool calls (assistant message)."},"tool_call_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tool Call Id","description":"Tool call ID (tool messages)."}},"additionalProperties":false,"type":"object","required":["role"],"title":"Message","description":"OpenAI-style chat message."},"TextContentPart":{"properties":{"type":{"type":"string","const":"text","title":"Type","description":"Content part type.","default":"text"},"text":{"type":"string","title":"Text","description":"Text content."}},"type":"object","required":["text"],"title":"TextContentPart","description":"Text content part in a message."},"ImageContentPart":{"properties":{"type":{"type":"string","const":"image_url","title":"Type","description":"Content part type.","default":"image_url"},"image_url":{"additionalProperties":true,"type":"object","title":"Image Url","description":"Image URL object with 'url' and optional 'detail'."}},"type":"object","required":["image_url"],"title":"ImageContentPart","description":"Image content part in a message."},"ToolCall":{"properties":{"id":{"type":"string","title":"Id","description":"Tool call id."},"type":{"type":"string","const":"function","title":"Type","description":"Tool call type.","default":"function"},"function":{"$ref":"#/components/schemas/FunctionCall","description":"Function call details."}},"type":"object","required":["id","function"],"title":"ToolCall","description":"A tool call emitted by the model."},"FunctionCall":{"properties":{"name":{"type":"string","title":"Name","description":"Function name."},"arguments":{"type":"string","title":"Arguments","description":"JSON-encoded arguments."}},"type":"object","required":["name","arguments"],"title":"FunctionCall","description":"Function call payload inside a tool call."},"ReasoningConfig":{"properties":{"effort":{"title":"Effort","description":"Reasoning effort level.","type":"string","enum":["none","minimal","low","medium","high","xhigh"],"nullable":true},"summary":{"title":"Summary","description":"Reasoning summary verbosity.","type":"string","enum":["auto","concise","detailed"],"nullable":true}},"type":"object","title":"ReasoningConfig","description":"Reasoning configuration for reasoning models."},"ResponseFormatText":{"properties":{"type":{"type":"string","const":"text","title":"Type","description":"Format type.","default":"text"}},"type":"object","title":"ResponseFormatText","description":"Plain text response format (default)."},"ResponseFormatJsonSchema":{"properties":{"type":{"type":"string","const":"json_schema","title":"Type","description":"Format type.","default":"json_schema"},"json_schema":{"$ref":"#/components/schemas/JsonSchemaConfig","description":"JSON schema configuration."}},"type":"object","required":["json_schema"],"title":"ResponseFormatJsonSchema","description":"Structured JSON output via a supplied schema."},"JsonSchemaConfig":{"properties":{"name":{"type":"string","title":"Name","description":"Schema name."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Schema description."},"schema":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Schema","description":"JSON Schema object."},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Strict","description":"Whether to enforce strict schema adherence."}},"type":"object","required":["name"],"title":"JsonSchemaConfig","description":"Configuration for json_schema response format."},"ResponseFormatJsonObject":{"properties":{"type":{"type":"string","const":"json_object","title":"Type","description":"Format type.","default":"json_object"}},"type":"object","title":"ResponseFormatJsonObject","description":"JSON object response format (legacy JSON mode)."},"StreamOptions":{"properties":{"include_usage":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Include Usage","description":"Include a final chunk with token usage statistics."}},"type":"object","title":"StreamOptions","description":"Options for streaming responses."},"ToolChoiceFunction":{"properties":{"type":{"type":"string","const":"function","title":"Type","description":"Tool choice type.","default":"function"},"function":{"$ref":"#/components/schemas/ToolChoiceFunctionName","description":"Function to call."}},"type":"object","required":["function"],"title":"ToolChoiceFunction","description":"Force the model to call a specific function."},"ToolChoiceFunctionName":{"properties":{"name":{"type":"string","title":"Name","description":"Function name."}},"type":"object","required":["name"],"title":"ToolChoiceFunctionName","description":"Specifies a function name to force-call."},"ToolDefinition":{"properties":{"type":{"type":"string","const":"function","title":"Type","description":"Tool type.","default":"function"},"function":{"$ref":"#/components/schemas/FunctionDefinition","description":"Function definition."}},"type":"object","required":["function"],"title":"ToolDefinition","description":"A tool the model may call."},"FunctionDefinition":{"properties":{"name":{"type":"string","title":"Name","description":"Function name."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Description of what the function does."},"parameters":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Parameters","description":"JSON Schema for the function parameters."},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Strict","description":"Whether to enforce strict schema adherence."}},"type":"object","required":["name"],"title":"FunctionDefinition","description":"Function definition inside a tool."},"TraceContext":{"properties":{"id":{"type":"string","title":"Id","description":"External trace identifier used to group requests."},"span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Span Id","description":"Optional span identifier within the trace."},"parent_span_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Span Id","description":"Optional parent span identifier."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Optional trace name."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source","description":"Optional trace source, e.g. langchain."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Optional metadata associated with the trace."}},"additionalProperties":false,"type":"object","required":["id"],"title":"TraceContext"},"ChatResRelaxed-Input":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Completion id."},"choices":{"items":{"$ref":"#/components/schemas/RegisterOutputChoice"},"type":"array","title":"Choices"},"created":{"anyOf":[{},{"type":"null"}],"title":"Created","description":"Creation timestamp (unix seconds)."},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model","description":"Model slug used."},"object":{"type":"string","const":"chat.completion","title":"Object","description":"Object type.","default":"chat.completion"},"usage":{"anyOf":[{"$ref":"#/components/schemas/ChatResponseUsage"},{"type":"null"}],"description":"Token usage."},"provider":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider","description":"Upstream provider name, if available."},"container":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Container","description":"Container label used for routing, if any."},"model_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model Id","description":"Model ID (uuid)."},"spend":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Spend","description":"Estimated spend."},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags","description":"Tags for this completion."},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata","description":"Metadata for this completion."},"trace":{"anyOf":[{"$ref":"#/components/schemas/TraceContext"},{"type":"null"}],"description":"Optional external trace/span context associated with this completion."}},"type":"object","required":["choices"],"title":"ChatResRelaxed"},"RegisterOutputChoice":{"properties":{"index":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Index","description":"Choice index."},"message":{"$ref":"#/components/schemas/RegisterOutputMessage"},"finish_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Finish Reason","description":"Reason the generation finished."}},"additionalProperties":true,"type":"object","required":["message"],"title":"RegisterOutputChoice"},"RegisterOutputMessage":{"properties":{"role":{"type":"string","title":"Role","description":"Message role (system, user, assistant)."},"content":{"anyOf":[{"type":"string"},{"items":{},"type":"array"},{"type":"null"}],"title":"Content","description":"Message content (string or structured parts)."}},"additionalProperties":true,"type":"object","required":["role"],"title":"RegisterOutputMessage"},"ChatResponseUsage":{"properties":{"prompt_tokens":{"type":"number","title":"Prompt Tokens","description":"Prompt tokens."},"completion_tokens":{"type":"number","title":"Completion Tokens","description":"Completion tokens."},"total_tokens":{"type":"number","title":"Total Tokens","description":"Total tokens."},"completion_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Completion Tokens Details"},"prompt_tokens_details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Prompt Tokens Details"}},"additionalProperties":true,"type":"object","required":["prompt_tokens","completion_tokens","total_tokens"],"title":"ChatResponseUsage","description":"Token usage in a chat completion response."},"RegisterRes":{"properties":{"ok":{"type":"boolean","title":"Ok","description":"Whether the register operation succeeded."},"container":{"type":"string","title":"Container","description":"Container label used for registration."},"summary":{"additionalProperties":true,"type":"object","title":"Summary","description":"Summary of inserted and skipped items."},"errors":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Errors","description":"Up to 200 validation or upsert errors."}},"additionalProperties":false,"type":"object","required":["ok","container","summary","errors"],"title":"RegisterChatCompletionsResponse"},"ErrorResponse":{"properties":{"error":{"$ref":"#/components/schemas/ManiacError","description":"Error payload."}},"additionalProperties":false,"type":"object","required":["error"],"title":"ErrorResponse","description":"Response body for errors."},"ManiacError":{"properties":{"code":{"type":"string","title":"Code","description":"Machine-readable error code."},"message":{"type":"string","title":"Message","description":"Human-readable error message."},"details":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Details","description":"Additional error details."}},"additionalProperties":false,"type":"object","required":["code","message"],"title":"ManiacError","description":"Standard Maniac API error envelope.\n\nThis matches the shape already used by v2 auth (`detail={\"error\": {...}}`)."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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"}}},"paths":{"/v1/chat/completions/register":{"post":{"tags":["Chat"],"summary":"Register chat completion examples","description":"Register completed chat examples for evaluation and analytics.\n\nThis endpoint accepts input/output pairs and stores them for later analysis,\nwhile aggregating usage metrics for reporting.","operationId":"chat_completions_register","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterReq"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterRes"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"429":{"description":"Too Many Requests","headers":{"X-RateLimit-Limit":{"description":"Request limit per window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in current window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp when the rate limit resets.","schema":{"type":"integer"}},"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Not Implemented","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Upstream Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```
