Claude Code
Set up Claude Code with Cognitivers, then verify your connection.
Anthropic's terminal agent. Speaks the Anthropic Messages API, so it needs a bridge.
Claude Code uses Anthropic Messages. Set up the LiteLLM bridge first, then connect Claude Code to it.
1. Before you begin
- Claude Code installed and ready to configure.
- A Cognitivers API key. See authentication and key management.
- A LiteLLM configuration for Cognitivers. Its access key authenticates Claude Code to the bridge.
Environment variables, or a local bridge in front of the API
Need an API key? Request access before running these examples.
2. Start the bridge
Save the configuration from the LiteLLM guide as cognitivers.yaml.
Run this in one terminal and leave it running:
litellm --config ./cognitivers.yaml3. Connect Claude Code
Open a second terminal. Set the variables below, replacing the token placeholder with the access key configured for your bridge. Launch Claude Code from this same terminal so it inherits those variables.
export ANTHROPIC_BASE_URL=http://localhost:4000
export ANTHROPIC_AUTH_TOKEN=sk-cog-...
export ANTHROPIC_DEFAULT_SONNET_MODEL=cog-pro
export ANTHROPIC_DEFAULT_HAIKU_MODEL=cog-fastCompatibility notes
- Claude Code posts to /v1/messages, not /v1/chat/completions. Without a bridge it cannot talk to this API.
- It counts every byte the bridge relays and aborts a stream that goes silent for 300 seconds, so the bridge must forward keep-alive pings during a long prefill.
- ANTHROPIC_AUTH_TOKEN sends Authorization: Bearer. ANTHROPIC_API_KEY would send X-Api-Key instead.
- CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 fills the /model picker from the /v1/models endpoint of the bridge.
4. Verify the setup
Use this prompt in your configured tool to check authentication, a response and streaming. It reports failures without printing your key.
Open verification prompt
You are working in a repository where I have configured Claude Code to use Cognitivers as its model provider.
The API is OpenAI-compatible chat completions.
- Base URL: https://api.cognitivers.com/v1
- Streaming: use the same base URL with stream: true
- Models: cog-fast (agents, pipelines, volume), cog-pro (one hard task), cog-embed (retrieval)
- Authentication: an API key in the Authorization header as "Bearer sk-cog-..."
Do these four things and then stop.
1. Check that the credential is present in my environment and tell me the name of the variable you found it in. Do not print the key itself, not even partially.
2. Send one non-streaming chat completion asking for a single short sentence, using cog-fast. Show me the exact command or code you used and the model's reply.
3. Send the same request with streaming enabled and confirm you received server-sent events, not one buffered body.
4. If any step fails, tell me the exact error, the status code and the request that produced it, then stop. Do not try more than two fixes, and do not change any configuration file without showing me the diff first.
Rules: never write the key into a file that is tracked by git, never print it in full, and if the request works, say so in one line instead of writing a report.
5. The bridge is the part that usually breaks. Confirm which protocol Claude Code speaks to it, and whether keep-alive lines from the API reach the client during a long read. Measure the time to first event and inspect timeout errors. A delayed first token alone does not prove buffering.If the check fails, use the reported status code in the error reference and review the compatibility notes above.