Anthropic Messages
Every NeMo Gym model server speaks the Anthropic Messages API in addition to Responses and Chat Completions. That means Anthropic-native harnesses — notably the Claude Code CLI — can target any Gym model backend (vLLM, OpenAI, Inference Providers, and so on) without a separate Anthropic proxy.
How it works
SimpleResponsesAPIModel registers POST /v1/messages on every model server by default. The handler maps the inbound Anthropic Messages request to Gym’s native Responses schema, calls that server’s own responses() implementation (whatever upstream the server is configured for), and maps the result back to an Anthropic Messages response. When the client sets stream: true (Claude Code always does), the complete response is re-emitted as a synthesized Anthropic SSE event stream.
You do not configure a separate “Claude model” server. Point Claude Code at any existing Gym model server URL; the /v1/messages dialect is already there.
Wire Claude Code to a Gym model server
The built-in claude_code_agent runs claude -p as a subprocess. Set its model_server ref to the Gym model server you want to use. That ref takes precedence over anthropic_base_url: the agent resolves ANTHROPIC_BASE_URL to the model server, and the CLI appends /v1/messages.
The showcase config reasoning_gym_claude_code_agent_model_server.yaml already wires model_server to policy_model. Compose it with any model server:
This path needs only the model server’s credentials (policy_base_url, policy_api_key, policy_model_name in env.yaml or as + overrides) — no anthropic_* variables.
Choose the right model type
Config snippet
To wire Claude Code yourself, set model_server on the agent and leave anthropic_base_url null:
With model_server set, model calls go through Gym and can be recorded by model-call capture. Direct Anthropic or anthropic_base_url runs bypass Gym capture.
Call Anthropic (or another Messages endpoint) directly
If you want Claude Code to hit Anthropic’s API — or any other host that already speaks /v1/messages — omit model_server and set the Anthropic credentials instead:
For a local vLLM or Ollama endpoint that already serves Messages:
anthropic_base_url must not include /v1. Claude Code appends /v1/messages itself.
Smoke-test /v1/messages
Launch a model server, take its URL from the gym env start log ('url': 'http://127.0.0.1:<port>'), then:
Related
- Agent runtime options (
bare, MCP, skills, thinking):claude_code_agentREADME - Skills evaluation pattern: Agent Skills
- MCP tools from a Resources Server: MCP Resources Server
- Capture model HTTP evidence: Model-call capture