Anthropic-compatible API
Serve Nucleus models to the Anthropic SDK and Claude Code with a base URL change.
Point the Anthropic SDK, Claude Code or any other Anthropic client at
https://api.nucleus-ai.io/anthropic and it talks to Nucleus models with no other changes.
The model parameter accepts a base model ID from
List base models or a nucleus:// sampler-weights path such as
nucleus://run_3Bz:train:0/sampler_weights/000240, so a fine-tuned model drops straight into
an existing Anthropic integration.
These routes accept Anthropic's native x-api-key header as well as the standard
Authorization: Bearer header. If both are present, Authorization wins. Both routes require
the infer scope. For a Claude Code setup walkthrough, see the
Anthropic compatibility guide.
Create a message
/anthropic/v1/messagesscope: inferGenerates an assistant turn from a conversation, following Anthropic's Messages API shape.
The response is a list of content blocks, including thinking blocks when the model reasons
before answering, and ends with a stop_reason such as end_turn. Streaming uses Anthropic's
SSE event format over text/event-stream; with cURL, add -N to disable buffering.
Body parameters
modelstringrequiredBase model ID or a nucleus:// sampler-weights path.
max_tokensintegerrequiredMaximum number of tokens to generate.
messagesarrayThe conversation so far, as role and content objects.
systemstringSystem prompt, rendered ahead of the conversation.
temperaturenumberSampling temperature.
top_pnumberNucleus sampling threshold.
top_kintegerSample only from the k most likely tokens at each step.
stop_sequencesarrayCustom sequences that stop generation when produced.
toolsarrayTool definitions the model may call, in Anthropic's tool schema.
tool_choiceobjectControls how the model chooses among tools.
streambooleanWhen true, the response is streamed using Anthropic's SSE event format.
thinkingobjectPass {"type":"disabled"} to turn off thinking blocks.
output_config.effortstringHow much effort the model spends on the response: a named level from low to max.
Prompt caching and citations are not supported.
curl https://api.nucleus-ai.io/anthropic/v1/messages \
-H "Authorization: Bearer $NUCLEUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nucleus://run_3Bz:train:0/sampler_weights/000240",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "What is 17 × 23?" }]
}'{
"type": "message",
"role": "assistant",
"content": [
{ "type": "thinking", "thinking": "17 × 23..." },
{ "type": "text", "text": "391" }
],
"stop_reason": "end_turn"
}Count tokens
/anthropic/v1/messages/count_tokensscope: inferReturns the exact input token count for a request, using the model's real tokenizer and
renderer. system and tools are counted when present, so the number matches what
Create a message would actually consume. Use it to quote the cost of a
request before running it.
Body parameters
modelstringrequiredBase model ID or a nucleus:// sampler-weights path.
messagesarrayrequiredThe conversation to count.
systemstringSystem prompt, counted if present.
toolsarrayTool definitions, counted if present.
curl https://api.nucleus-ai.io/anthropic/v1/messages/count_tokens \
-H "Authorization: Bearer $NUCLEUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nucleus://run_3Bz:train:0/sampler_weights/000240",
"messages": [{ "role": "user", "content": "What is 17 × 23?" }]
}'{
"input_tokens": 34
}