OpenAI-compatible chat completions proxy. Both paths use the same handler and always target the default AI provider. Only POST is allowed.
Send an OpenAI-style JSON body.
| REQUEST Field | Value Type | Description |
|---|---|---|
messages | array | Chat messages with roles such as system, user, assistant, and tool. |
stream | boolean | If true, the response is streamed as SSE text/event-stream. |
tool_choice | string | If set to required, tool execution is forced. |
tools | array | Client tools are not forwarded to the upstream provider. If omitted or empty, all server tools remain available. If the list contains the connection_test tool, only that server tool is used. |
timeout_ms | number | Timeout in milliseconds. Default: 120000. |
Non-streaming responses use an OpenAI chat.completion shape with fields such as id, object, created, model, and choices. Streaming responses send chunk events and end with data: [DONE]. Additional SSE events may carry tool progress.
If a custom default provider URL points back to this proxy endpoint, the request returns 409 Conflict. Missing default provider returns 404. Timeout returns 504. Provider failures return 502. Wrong methods return 405.
# Request POST /api/ai/chat/completions HTTP/1.1 Host: helpdesk.example.com Authorization: Bearer <access_token> Content-Type: application/json { "messages": [ { "role": "user", "content": "Hello" } ], "stream": false, "timeout_ms": 120000 } # Response HTTP/1.1 200 OK Content-Type: application/json { "id": "chatcmpl-example", "object": "chat.completion", "created": 1710000000, "model": "inet-ai-proxy", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I help?" }, "finish_reason": "stop" } ] }
Note: POST /api/ai/v1/chat/completions behaves identically to POST /api/ai/chat/completions.