Skip to content

Nebius Token Factory

Nebius Token Factory provides fast inference for open-source language models. Nebius Token Factory is accessible through OpenAI’s SDK via full API compatibility, allowing easy and portable integration with the Strands Agents SDK using the familiar OpenAI interface.

The Strands Agents SDK provides access to Nebius Token Factory models through the OpenAI compatibility layer, configured as an optional dependency. To install, run:

Terminal window
pip install 'strands-agents[openai]' strands-agents-tools

After installing the openai package, you can import and initialize the Strands Agents’ OpenAI-compatible provider for Nebius Token Factory models as follows:

from strands import Agent
from strands.models.openai import OpenAIModel
from strands_tools import calculator
model = OpenAIModel(
client_args={
"api_key": "<NEBIUS_API_KEY>",
"base_url": "https://api.tokenfactory.nebius.com/v1/",
},
model_id="deepseek-ai/DeepSeek-R1-0528", # or see https://docs.tokenfactory.nebius.com/ai-models-inference/overview
params={
"max_tokens": 5000,
"temperature": 0.1
}
)
agent = Agent(model=model, tools=[calculator])
agent("What is 2+2?")

The client_args configure the underlying OpenAI-compatible client. When using Nebius Token Factory, you must set:

  • api_key: Your Nebius Token Factory API key. Get one from the Nebius Token Factory Console.
  • base_url: https://api.tokenfactory.nebius.com/v1/

Refer to OpenAI Python SDK GitHub for full client options.

The model_config specifies which Nebius Token Factory model to use and any additional parameters.

ParameterDescriptionExampleOptions
model_idModel namedeepseek-ai/DeepSeek-R1-0528See Nebius Token Factory Models
paramsModel-specific parameters{"max_tokens": 5000, "temperature": 0.7, "top_p": 0.9}API reference

ModuleNotFoundError: No module named 'openai'

Section titled “ModuleNotFoundError: No module named 'openai'”

You must install the openai dependency to use this provider:

Terminal window
pip install 'strands-agents[openai]'

Ensure you’re using a model ID compatible with Nebius Token Factory (e.g., deepseek-ai/DeepSeek-R1-0528, meta-llama/Meta-Llama-3.1-70B-Instruct), and your base_url is set to https://api.tokenfactory.nebius.com/v1/.