API docs
API reference

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

POST/anthropic/v1/messagesscope: infer

Generates 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

modelstringrequired

Base model ID or a nucleus:// sampler-weights path.

max_tokensintegerrequired

Maximum number of tokens to generate.

messagesarray

The conversation so far, as role and content objects.

systemstring

System prompt, rendered ahead of the conversation.

temperaturenumber

Sampling temperature.

top_pnumber

Nucleus sampling threshold.

top_kinteger

Sample only from the k most likely tokens at each step.

stop_sequencesarray

Custom sequences that stop generation when produced.

toolsarray

Tool definitions the model may call, in Anthropic's tool schema.

tool_choiceobject

Controls how the model chooses among tools.

streamboolean

When true, the response is streamed using Anthropic's SSE event format.

thinkingobject

Pass {"type":"disabled"} to turn off thinking blocks.

output_config.effortstring

How 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?" }]
  }'
200 OK
{
  "type": "message",
  "role": "assistant",
  "content": [
    { "type": "thinking", "thinking": "17 × 23..." },
    { "type": "text", "text": "391" }
  ],
  "stop_reason": "end_turn"
}

Count tokens

POST/anthropic/v1/messages/count_tokensscope: infer

Returns 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

modelstringrequired

Base model ID or a nucleus:// sampler-weights path.

messagesarrayrequired

The conversation to count.

systemstring

System prompt, counted if present.

toolsarray

Tool 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?" }]
  }'
200 OK
{
  "input_tokens": 34
}
Anthropic-compatible API | Nucleus AI API