Skip to content

Claude Code → Azure OpenAI: 400 Invalid 'user': string too long (metadata.user_id forwarded verbatim) #5705

Closed

Description

@giulioleone097

Client or integration

Claude Code

Area

Proxy and routing

Summary

Claude Code requests routed to an Azure OpenAI model fail with HTTP 400, because anthropicToResponsesTranslation copies metadata.user_id verbatim into the Responses user field.

Claude Code sends metadata.user_id as a JSON string (device id, account uuid, session id) of about 186 characters. OpenAI-compatible Responses backends such as Azure OpenAI cap user at 64 characters and reject the request. The ChatGPT backend accepts it, so Codex-native routes work, while every Azure route from Claude Code or the Claude Desktop Code tab fails.

The value is copied at src/claude/inbound.ts:445 (body.user = raw.metadata.user_id;). The same block already hashes user_id to build prompt_cache_key.

Reproduction

  1. Configure an azure-openai provider (adapter: "azure-openai", base URL https://<resource>.services.ai.azure.com/openai/v1) with gpt-6-astra.
  2. Apply the first-party Claude Desktop profile with ocx claude desktop apply, or launch through ocx claude.
  3. Run claude -p "Reply only: OK" --model <slot alias of azure-openai/gpt-6-astra>.
  4. The request fails. The same prompt sent with curl to /v1/messages without metadata succeeds, and a Codex-native slot such as gpt-5.6-sol (native) succeeds from Claude Code.

Version

2.64.0 (npm, latest)

Operating system

macOS (Darwin 27.0.0, arm64)

Provider and model

azure-openai / gpt-6-astra, gpt-5.6-sol

Logs or error output

API Error: 400 Invalid 'user': string too long. Expected a string with maximum length 64, but got a string with length 186 instead.

Suggested fix

Keep user when it has 64 characters or fewer. Otherwise send the SHA-256 hex digest (64 characters) that the block already computes for prompt_cache_key. I verified this locally: Azure slots answer normally from Claude Code, and native and Anthropic routes are unaffected. A PR follows.

Activity

  1. added
    bugSomething isn't working
    providerProvider adapters, OpenAI-compat presets, upstream API quirks
    proxyHTTP proxy, routing, reverse-proxy / management auth
    on Sep 23, 2026
  2. added a commit that references this issue on Sep 24, 2026
    df61bce
  3. lidge-jun commented on Sep 24, 2026

    @lidge-jun
    Owner

    Fixed on dev by bundle #5738 (squash-merged as df61bce); it will ship in the next release. Closing manually because dev is not the default branch, so GitHub does not auto-close. If you still see this on a build that includes df61bce, please reopen with the version and a redacted reproduction.

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

    bugSomething isn't workingproviderProvider adapters, OpenAI-compat presets, upstream API quirksproxyHTTP proxy, routing, reverse-proxy / management auth

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions