nexusflow
Online
Claude Messages API

Claude API integration

NexusFlow's /v1/messages supports both native Anthropic Claude models and compatible-layer models. When model is claude-*, requests go directly to Anthropic's official Messages API, preserving the native response and SSE event format.

Endpoint

POSThttps://nexusflow.vip/v1/messagesSync / Streaming

Request Parameters

ParametersRequiredDescription
modelYesClaude model ID, e.g. claude-sonnet-4-6, claude-opus-4-7
messagesYesAnthropic Messages format message array
max_tokensYesMaximum output token count
streamNoWhen set to true, returns an Anthropic SSE event stream
systemNoSystem prompt, using Anthropic's top-level system field
toolsNoAnthropic tool definitions; Claude models will forward them to the official API

Supported Models and Official Pricing

ModelscontextMax outputUSD / MTok input/output
claude-opus-4-71M128K$5 / $25
claude-sonnet-4-61M64K$3 / $15
claude-haiku-4-5200K64K$1 / $5

Invocation Examples

curl https://nexusflow.vip/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain what a model gateway is in three sentences"}
    ]
  }'
curl https://nexusflow.vip/v1/messages \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a product launch copy snippet"}
    ]
  }'

Prompt Caching (Context Caching)

Calling via /v1/messages supports Prompt Caching. Add cache_control annotations to content blocks in system or messages; repeated prefixes will be cached, and subsequent requests that hit the cache receive a 90% discount:

Token TypeBillingMultiplierDescription
cache_creation_input_tokens1.25xFirst-time write to input cache
cache_read_input_tokens0.1xCache hit, 90% discount
input_tokens1xUncached portion, normal billing

Usage example: Add "cache_control": {"type": "ephemeral"} to the system block. Suitable for long system prompts, document context, and other repeated content. Both Claude direct and NexusFlow compatible models support this.

Related Docs