SambaNova also supports the Anthropic Messages API. See Anthropic compatibility and the Messages API page.
Download the library
Run the command below to download the library.Use SambaNova APIs with OpenAI client libraries
Configure your OpenAI client libraries to use SambaNova inference APIs by setting two values: thebase_url and your api_key.
Don’t have a SambaNova API key? Get yours from the API keys and URLs page.
Non-streaming example
The following code demonstrates using the OpenAI Python client for non-streaming completions.Streaming example
The following code demonstrates using the OpenAI Python client for streaming completions.In streaming mode, the API returns chunks that contain multiple tokens. When calculating metrics like tokens per second or time per output token, count all tokens in each chunk.
Responses API
In addition to the Chat Completions endpoint, SambaNova exposes a Responses API endpointPOST /v1/responses that is compatible with the OpenAI Responses API standard. If you already use the OpenAI SDK with the Responses API, you can point it to SambaNova with the same configuration.
Currently unsupported OpenAI features
presence_penalty and frequency_penalty accept only 0, their default. Any other value returns HTTP 400. To penalize repetition, use repetition_penalty on models that support it.
On SambaCloud, parameters that are not part of the SambaNova API return HTTP 400 instead of being ignored. See Unknown request parameters.
Feature differences
n: The SambaNova API supports values 1–8 (integer, default 1). OpenAI has no documented hard cap. Note that n greater than 1 is not supported when using function calling or tools – combining them returns a 400 error.
seed: Supported on both SambaStack and SambaCloud for text generation models. Passing the same seed with the same inputs produces deterministic outputs. Accepts any integer, including negative values.
Unlike OpenAI, the SambaNova API does not return a
system_fingerprint field in the response. The seed parameter is not supported for multi-modality models or continuous batching (CB) models.logit_bias
Accepts a JSON object mapping token IDs to bias values between -100 and 100. Negative values discourage the corresponding tokens; positive values encourage them. Token IDs are model-specific – look them up using the target model’s tokenizer.
Support for logit_bias is set per model deployment, not per model name. It depends on how the deployment’s model was compiled, so two deployments of the same model can behave differently. On SambaStack, a deployment is a bundle; see Supported models and bundles.
The
logit_bias parameter is not supported for multimodal models. A request that sets logit_bias on a deployment that cannot apply it returns HTTP 400 instead of ignoring the parameter:
error, error_type, error_param, and error_code.
The number of logit_bias entries a request can include depends on the deployment. The current gpt-oss-120b bundles accept up to 300. A request with more entries than the deployment allows also returns HTTP 400, and the error message states the deployment’s limit.
A token ID outside the model’s vocabulary returns HTTP 400 with code set to invalid_value and the message Token id <id> is out of the vocabulary range. This check runs before the request reaches the deployment, so the error uses the format on API error codes on every endpoint, including chat completions. It also takes precedence: an out-of-range token ID on a deployment that does not support logit_bias returns this error, not the unsupported error.
Because support depends on the deployment, handle the HTTP 400 response in your client rather than assuming support from the model name. Check for HTTP 400 with
param set to logit_bias (error_param in the flat format). If code is invalid_value, correct the token ID. Otherwise, retry without logit_bias or send the request to a deployment that supports it.SambaNova API features not supported by OpenAI clients
The SambaNova API supports thetop_k parameter, which is not supported by the OpenAI client libraries.
