Repository navigation
Closed
Labels
area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:mediumMedium prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions
Milestone
Description
mlxcel-server exposes an OpenAI-compatible API (chat completions and the Responses API), but it has no Anthropic Messages-style endpoint, so clients written against the Anthropic Messages schema cannot talk to mlxcel-server without a translation shim.
Goal
Add a POST /v1/messages endpoint (with a /messages alias) that accepts the Anthropic Messages request schema and returns Anthropic-style responses, in both synchronous and SSE streaming modes. Add POST /v1/messages/count_tokens (with a /messages/count_tokens alias) for prompt token counting.
Scope
- Request schema: top-level
system(string or text-block array),messages,max_tokens,stop_sequences,temperature/top_p/top_k, functiontools+tool_choice, andthinking. - Content blocks:
text,image(base64 and url),tool_use, andtool_result, including image content nested insidetool_resultblocks so vision models can consume tool-produced images. - Streaming: emit the Anthropic SSE event sequence (
message_start,content_block_start/delta/stop,message_delta,message_stop,error), withusagepopulated on both the non-streaming response and the streamingmessage_delta. - Reuse the existing generation, chat-template, media, tool-call, and thinking-budget plumbing rather than duplicating the generation loop. Translate the Anthropic request into the server's internal chat-completion representation, and assemble Anthropic content blocks on the way out, structured similarly to the existing Responses API endpoint.
- Map stop reasons and apply stop-sequence truncation consistent with the Anthropic schema.
- Bound the
count_tokenspath against unbounded tool arrays so it cannot be used to exhaust server resources.
Acceptance criteria
POST /v1/messageshandles both sync and streaming requests and returns schema-valid Anthropic responses.POST /v1/messages/count_tokensreturns a prompt token count and rejects oversized tool arrays.- Images supplied directly and images nested inside
tool_resultblocks both reach vision models. - Non-streaming and streaming responses both populate
usage. - Unit tests cover request translation, content-block assembly, stop-reason mapping, and the streaming state machine.
Metadata
Metadata
Assignees
Labels
area:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:mediumMedium prioritystatus:doneCompletedtype:enhancementNew features, capabilities, or significant additions
Activity