Skip to main content
POST
/
messages
JavaScript
import SambaNova from 'sambanova';

const client = new SambaNova({
  apiKey: process.env['SAMBANOVA_API_KEY'], // This is the default and can be omitted
});

const message = await client.messages.create({
  max_tokens: 1024,
  messages: [{ content: 'Hello, Claude!', role: 'user' }],
  model: 'DeepSeek-V3.1',
});

console.log(message);
{
  "id": "<string>",
  "content": [
    {
      "text": "<string>",
      "citations": [
        {}
      ]
    }
  ],
  "model": "<string>",
  "usage": {
    "input_tokens": 123,
    "output_tokens": 123,
    "cache_creation_input_tokens": 123,
    "cache_read_input_tokens": 123,
    "server_tool_use": {},
    "service_tier": "<string>",
    "cache_creation": {},
    "inference_geo": "<string>"
  },
  "stop_sequence": "<string>",
  "stop_details": {},
  "container": {
    "id": "<string>",
    "expires_at": "<string>"
  }
}

Authorizations

Authorization
string
header
required

SambaNova API key, sent as a bearer token in the Authorization header (Authorization: Bearer <key>). Default authentication scheme used by the SambaNova SDK across every OpenAI compatible endpoint.

Headers

anthropic-version
string

Anthropic API version header sent by the official anthropic SDK. Accepted (any value) but currently has no effect on response shape — included for drop-in SDK compatibility.

Example:

"2023-06-01"

Body

application/json

Message creation parameters.

Request body for POST /messages. Wire-compatible with the official Anthropic Messages API. Required fields: model, max_tokens, messages.

model
required

The model ID to use (e.g. gpt-oss-120b). See available models

Example:

"gpt-oss-120b"

max_tokens
integer
required

Maximum number of tokens to generate. The combined input + output token count is bounded by the model's context window.

Required range: x >= 1
Example:

1024

messages
Message Input Message · object[]
required

Conversation turns.

Minimum array length: 1
system

System prompt for the conversation. Accepts either a single string (most common) or an array of text blocks (used when individual segments need cache_control markers). Multiple text blocks are joined with newlines and prepended to the conversation as a role: system message.

temperature
number | null

Sampling temperature in [0.0, 2.0]. Higher values produce more random output, lower values more deterministic. Adjust only one of temperature, top_p, top_k.

Required range: 0 <= x <= 2
Example:

1

top_p
number | null

Nucleus sampling. Considers tokens with cumulative probability mass up to top_p.

Required range: 0 <= x <= 1
top_k
integer | null

Top-k sampling. Considers only the K most likely tokens at each step. Set to 0 to disable.

Required range: x >= 0
stop_sequences
string[] | null

Custom strings that, when generated, cause the model to stop.

stream
boolean | null
default:false

If true, the response is a sequence of Server-Sent Events whose payloads conform to MessageStreamEvent.

metadata
Message Metadata · object

Free-form metadata attached to the request. Currently only user_id Additional fields are accepted but ignored.

thinking
Message Thinking Disabled · object

Disables Anthropic-style extended thinking. In v1: silently accepted as a no-op

tools
Message Tool · object[] | null

Tool definitions the model may call.

tool_choice
Message Tool Choice (Auto) · object

Controls how the model selects from tools.

service_tier
enum<string> | null

Service-tier preference. In v1: silently dropped

Available options:
auto,
standard_only
container
string | null

Existing code-execution container ID to reuse. In v1: silently dropped

Response

Successful response. Returns a Message object (non-streaming), or a stream of Server-Sent Events whose payloads conform to MessageStreamEvent ending with a message_stop event (when stream: true).

Non-streaming response from POST /messages. Wire-compatible with the official Anthropic Messages API.

id
string
required

Unique identifier for this message.

type
enum<string>
required
Available options:
message
Allowed value: "message"
role
enum<string>
required
Available options:
assistant
Allowed value: "assistant"
content
(Message Output Text Block · object | Message Output Tool Use Block · object | Message Output Thinking Block · object | Message Output Redacted Thinking Block · object | Message Output Server Tool Use Block · object | Message Output Web Search Tool Result Block · object | Message Output Web Fetch Tool Result Block · object | Message Output Code Execution Tool Result Block · object | Message Output Bash Code Execution Tool Result Block · object | Message Output Text Editor Code Execution Tool Result Block · object | Message Output Tool Search Tool Result Block · object | Message Output Container Upload Block · object)[]
required

Plain-text segment of the model's response.

model
string
required

Model that produced the response.

stop_reason
enum<string>
required

Reason the model stopped generating. SambaNova emits end_turn, max_tokens, tool_use, and stop_sequence. The remaining values are defined for Anthropic SDK type-parity but never returned: pause_turn (server-tool loop limit, not produced); refusal (content filter, not exposed); model_context_window_exceeded (folded to max_tokens).

Available options:
end_turn,
max_tokens,
tool_use,
pause_turn,
refusal,
stop_sequence,
model_context_window_exceeded
usage
Message Usage · object
required

Token accounting for the request.

stop_sequence
string | null

The matched stop sequence that triggered termination. Present when stop_reason is stop_sequence; null otherwise.

stop_details
Message Stop Details · object

Refusal stop details. Anthropic compatibility only — refusal is never emitted as a stop_reason by SambaNova (content filtering is not exposed at the API layer).

container
Message Container · object

Code-execution container reference. Anthropic compatibility only — SambaNova does not run server-side code execution, so this field is never emitted on responses.