Skip to content

[Feature]: Native OpenAI Chat Completions Proxy Endpoint (/v1/chat/completions) #208

Closed

Description

@mohamedabduissa

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

  1. 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 } }

  1. 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

  1. Wibias commented on Jul 21, 2026

    @Wibias
    Contributor

    @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.

  2. lidge-jun commented on Jul 22, 2026

    @lidge-jun
    Owner

    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:

    1. Which endpoint shape you need (POST /v1/chat/completions OpenAI-compatible?) and from which client/tool?
    2. Whether you need streaming (SSE) support, tool/function calling, or both?
    3. A sample request that currently fails, with the expected response shape?

    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.

  3. changed the title [-][Feature]: need to add function chat/completions for compatible open AI in api section[/-] [+][Feature]: Native OpenAI Chat Completions Proxy Endpoint (/v1/chat/completions)[/+] on Jul 22, 2026
  4. mohamedabduissa commented on Jul 22, 2026

    @mohamedabduissa
    Author

    @lidge-jun Thank you for your response. I updated everything you needed

  5. lidge-jun commented on Jul 22, 2026

    @lidge-jun
    Owner

    Status update: PR #279 implements exactly this — a general OpenAI-compatible POST /v1/chat/completions endpoint (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, and output_item.done final-arguments reconciliation) are pending. Track #279 for progress — once it merges, this issue closes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions