Use Claude Code with Datagram

Run Anthropic's Claude Code coding agent on open models hosted on our own Apple Silicon, so your code stays on private hardware.

Works with Datagram AI

All guides · API quickstart · Last checked: Claude Code 2.1.330, November 2026

  1. 1. Create an accountSign up in a minute and get $5 of free credit. Already a customer? Sign in.
  2. 2. Make an API keyIn your account, open AI API and press Create key. Keys start with dgk_. Keep yours secret.
  3. 3. Follow the steps belowCopy each block, paste your key where it says dgk_your_key_here.

1. Add the settings

Claude Code reads its settings from ~/.claude/settings.json in your home folder. Create it, or add the env block to the one you have, and put in your key:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.datagram.net",
    "ANTHROPIC_AUTH_TOKEN": "dgk_your_key_here",
    "ANTHROPIC_MODEL": "qwen3-coder:30b-64k",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3-coder:30b-64k",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3-coder:30b-64k",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3-coder:30b-64k",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3-coder:30b-64k",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "65536",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

Prefer environment variables? The same names work as export ANTHROPIC_BASE_URL=https://api.datagram.net and so on, in your shell profile.

2. Check the connection

This sends one short message. A reply with "type":"message" means the address and key are right:

curl https://api.datagram.net/v1/messages \
  -H "Authorization: Bearer dgk_your_key_here" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "qwen3-coder:30b-64k", "max_tokens": 50,
       "messages": [{"role": "user", "content": "Say hello"}]}'

3. Start Claude Code

Open a terminal in your project and run claude as usual. Ask it to read a file or fix something small first. The first answer can take 10 to 20 seconds while the model loads; after that it's quicker.

You may see "Claude Code doesn't recognize the model". That's expected for any model that isn't Claude, and with the settings above it works normally.

Which model?

ModelGood for
qwen3-coder:30b-64kRecommended. Fast, reliable with Claude Code's tools (reading, editing, running commands), 64K tokens of room.

Other models in our list have shorter windows (8K tokens) and are too small for Claude Code's instructions. Larger coding models with long windows are coming; tell us which you'd like.

If something goes wrong

401 or "Invalid or revoked API key"

Check ANTHROPIC_AUTH_TOKEN holds your dgk_ key with no spaces, and that ANTHROPIC_BASE_URL is https://api.datagram.net. If you also have ANTHROPIC_API_KEY set (for Anthropic itself), unset it while using Datagram.

"is not one of our models" naming a claude-… model

One of the five model settings is missing, so Claude Code asked for a Claude model. Add all of them, then restart Claude Code.

402 "credit has run out"

Add credit in your account under AI API. Credit never expires.

It ignores files or forgets what it was doing

Check CLAUDE_CODE_MAX_CONTEXT_TOKENS is set to 65536 and that you're using qwen3-coder:30b-64k, not a model without -64k.

Agents that run Claude Code for you on the same computer use these settings too.

Questions

Does this use Anthropic's Claude models?

No. Claude Code is the tool; the model answering is an open model on our hardware (Qwen3-Coder by default). Open models are good at everyday coding tasks but are not as strong as Anthropic's largest Claude models on hard problems.

Why the 64K model?

Claude Code sends long instructions with every request, about 10,000 tokens before your own code. qwen3-coder:30b-64k has room for 65,536 tokens, so Claude Code has space to read files and keep a conversation going. Models with smaller windows cut the instructions off and behave badly.

What does it cost?

The normal token price of the model you choose, from your Datagram credit. Claude Code resends its instructions and your conversation with every step; the repeated part is cached input and costs a tenth of the normal input price. You can see your use in your account under AI API.

Does Anthropic see my code?

Not through these requests: they go to datagram.net and run on our Macs, and we never store prompts or answers. Setting CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC also turns off Claude Code's own update checks and usage reporting to Anthropic.

Claude Code says the model isn't recognized. Is something wrong?

No. Claude Code warns about any model name it doesn't know. With CLAUDE_CODE_MAX_CONTEXT_TOKENS set it uses the right window size and works normally.

Create an account Get an API key More guides →