Repository navigation
[Feature]: Native OpenAI Chat Completions Proxy Endpoint (/v1/chat/completions) #208
Description
Problem to solve
Add a native OpenAI-compatible Chat Completions endpoint (POST /v1/chat/completions) to translate standard OpenAI request payloads into the internal Responses API format (/v1/responses) and format all responses back to standard OpenAI Chat Completion objects (both streaming and non-streaming).
Proposed solution
Endpoint Specification
Endpoint: POST /v1/chat/completions
Content-Type: application/json
Headers: Authorization: Bearer <API_KEY>
Request Payload (ChatCompletionRequest)
Input Parameters:
`
{
"model": "string",
"messages": [
{
"role": "system | user | assistant | tool",
"content": "string | array",
"name": "string (optional)",
"tool_calls": "array (optional)"
}
],
"stream": false,
"temperature": 0.7,
"top_p": 1.0,
"max_tokens": 1024,
"stop": ["string"],
"frequency_penalty": 0.0,
"presence_penalty": 0.0,
"tools": ["array (optional)"],
"tool_choice": "string | object (optional)",
"response_format": "object (optional)"
}
`
Response Specification
- Non-Streaming (stream: false)
Response Status: 200 OK
Content-Type: application/json
Return Structure: Standard OpenAI ChatCompletionResponse object.
{ "id": "chatcmpl-1721641000", "object": "chat.completion", "created": 1721641000, "model": "deepseek-r1", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Response text here...", "reasoning_content": "Reasoning/thinking process (if model supports reasoning)", "tool_calls": [] }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 50, "completion_tokens": 150, "total_tokens": 200 } }
- Streaming (stream: true)
Response Status: 200 OK
Content-Type: text/event-stream
Headers:
Cache-Control: no-cache
Connection: keep-alive
X-Accel-Buffering: no
Return Structure: Server-Sent Events (SSE) yielding OpenAI delta chunks ending with data: [DONE].
`data: {"id":"chatcmpl-1721641000","object":"chat.completion.chunk","created":1721641000,"model":"deepseek-r1","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-1721641000","object":"chat.completion.chunk","created":1721641000,"model":"deepseek-r1","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-1721641000","object":"chat.completion.chunk","created":1721641000,"model":"deepseek-r1","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
`
Core Internal Functions Required
chat_completions(request: Request, body: ChatCompletionRequest, authorization: str | None)
Main router function directing traffic based on body.stream.
execute_non_streaming(body: ChatCompletionRequest) -> dict
Maps incoming messages/tools to upstream /v1/responses format, fires single async HTTP POST, decodes output/reasoning, and formats OpenAI response.
execute_streaming(body: ChatCompletionRequest) -> AsyncIterator[str]
Opens stream connection to upstream SSE, parses events (response.created, response.output_item.added, response.content_part.added, response.text.delta, response.done), formats and yields OpenAI-compliant SSE chunks (data: {...}\n\n).
Alternatives considered
No response
Additional context
No response
Activity
Wibias commentedon Jul 21, 2026
@mohamedabduissa We all do this for free in our free time. Please put a bit more effort into it and say exactly what kind of feature you would like.
Cause not even putting in more then two sentences is everything else, but not respecting the work being done.
lidge-jun commentedon Jul 22, 2026
Thanks for the request. To scope this properly we need a concrete contract, since "chat/completions compatibility" can mean very different things. Could you specify:
POST /v1/chat/completionsOpenAI-compatible?) and from which client/tool?With a reproducible example we can evaluate this against the existing responses/adapters surface. Without a concrete contract we can't act on it, so this stays open pending details.
[-][Feature]: need to add function chat/completions for compatible open AI in api section[/-][+][Feature]: Native OpenAI Chat Completions Proxy Endpoint (/v1/chat/completions)[/+]mohamedabduissa commentedon Jul 22, 2026
@lidge-jun Thank you for your response. I updated everything you needed
ci: improve issue intake, enforce minimum quality, and ping PR author…
lidge-jun commentedon Jul 22, 2026
Status update: PR #279 implements exactly this — a general OpenAI-compatible
POST /v1/chat/completionsendpoint (streaming + tool calls), initially motivated by Copilot App support. First review round's four blockers are fixed; two remaining blockers (error responses currently masked as HTTP 200, andoutput_item.donefinal-arguments reconciliation) are pending. Track #279 for progress — once it merges, this issue closes.ci: improve issue intake, enforce minimum quality, and ping PR author…