Repository navigation
feat(http): Anthropic Messages API at /v1/messages - #138
Merged
Merged
Conversation
…d the Anthropic SDKs
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Streamed tool calls open once their name is complete and send no null arguments, stream write errors stop the vendor stream, mid-stream errors use the shared error mapping, count_tokens does not fetch url sources, Claude Code's session-scoped user_id keeps its device or account as the user, and budget estimates count tools and tool calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code (
ANTHROPIC_BASE_URL) and the Anthropic SDKs run through Keystone with a KTMS key. Experimental in 1.x.POST /v1/messagesturns a Messages request into the sameGenerateTextrequest as chat completions: routing, fallback, limits, guardrails, cache,X-KTMS-*headers and usage events are shared, and any vendor's answer is rendered as a Messages response.system(string or text blocks),text/image/document/tool_use/tool_resultblocks, clienttoolswithinput_schema,tool_choice,max_tokens(required),metadata.user_id, the key inx-api-keyorAuthorization. Thinking and server-tool blocks in assistant turns are dropped; server tools are rejected with 400.message_start,ping,content_block_*(text_delta,input_json_delta),message_delta,message_stop; errors after the first byte are anerrorevent.POST /v1/messages/count_tokens: an estimate, markedX-KTMS-Token-Count: estimate.writeAPIError, the route headers andwrapare split so both formats share them;grpcapi.EstimateTokensis exported formessage_startandcount_tokens.Checked live against a scripted OpenAI-compatible vendor behind KTMS: Claude Code 2.1.287 (
claude -p,ANTHROPIC_API_KEYandANTHROPIC_AUTH_TOKEN) runs a session with streaming and a Bash tool call; the Python (2.3.0) and TypeScript (1.3.0) SDKs create, stream, send tool results, count tokens and raise typed errors unpatched; usage events in light-tokenmeter are the same as for chat completions.Closes ai-process/docs#184