Skip to main content
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:
Checkout the example notebook in our cookbook repository.
Aisuite works only with text-to-text models.

Prerequisites

  1. Create an API key to authorize requests to Nebius Token Factory.
  2. Save the API key into a NEBIUS_API_KEY environment variable:
  3. Install the aisuite and openai packages:

Create a chat completion

Paste the following code into your script:
Change the code to fit your needs:
  • 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 messages to 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.