You can use the aisuite open-source package to work with Nebius Token Factory in Python. aisuite provides a standardized interface that extends the OpenAI Python SDK and simplifies integration with different AI providers. Thanks to its built-in support for the Nebius Token Factory endpoint and API keys, you can make requests to models as simple as the following:Documentation Index
Fetch the complete documentation index at: https://docs.tokenfactory.nebius.com/llms.txt
Use this file to discover all available pages before exploring further.
Checkout the example notebook in our cookbook repository.
Aisuite works only with text-to-text models.
Prerequisites
- Create an API key to authorize requests to Nebius Token Factory.
-
Save the API key into a
NEBIUS_API_KEYenvironment variable: -
Install the
aisuiteandopenaipackages:
Create a chat completion
Paste the following code into your script:-
To work with a different model, change
model_id. You can copy the model ID from the model card or look it up in the list. -
Modify
messagesto get the model’s responses to your questions. To work with a larger context, you can also add previous responses from the model. For example:
Checkout the example notebook in our cookbook repository.