Prerequisites
- Create an API key to authorize requests to Nebius AI Studio.
- If you want to work with Nebius AI Studio models in the Hugging Face Model Hub, add the Nebius AI Studio API key to your Hugging Face account:
- Create a Hugging Face account.
- Go to the Inference Providers section in your Hugging Face user account settings.
- In the Nebius AI Studio row, click the key icon in the Routing mode column.
- In the window that opens, enter your Nebius AI Studio API key.
You can choose not to use the Nebius AI Studio API key. In this case, you can still work with the models, but then you pay for their usage via your Hugging Face account.
-
If you want to work with Nebius AI Studio models via the Hugging Face SDK, install the Hugging Face libraries for the programming language that you prefer:
Install the huggingface_hub package (version v0.29.0 or later):
How to work with Nebius AI Studio models in the Hugging Face Model Hub
The Hugging Face Model Hub enables you to see models, review information about them on model cards and interact with models directly in the browser.
To work with Nebius AI Studio models:- Go to the Models section.
- Make sure that Nebius AI Studio is selected in the Other → Inference Providers filter.
- Go to the page of the required model.
- In the Inference Providers section, select Nebius AI Studio.
- Interact with the model in the same section. For example, if you selected a text-to-text model, you can send a prompt to it. If you want to work with a model in the Hugging Face playground where you can change the model settings, click Open playground.
How to work with Nebius AI Studio models via the Hugging Face SDK
Text-to-text models
Use theInferenceClient
class by Hugging Face to send a multi-message request.
Specify your API key in this class. You can use either a Nebius AI Studio API key or a Hugging Face API key to work with the SDK. Depending on your choice, you are billed for the model usage via your Nebius AI Studio or Hugging Face account.
- To work with a different model, change the
model
parameter. See a list of available models. - Modify
messages
to specify your questions.
Text-to-image models
Use theInferenceClient
class by Hugging Face to generate images.
Specify your API key in this class. You can use either a Nebius AI Studio API key or a Hugging Face API key to work with the SDK. You are billed for model usage in the service whose key you use.
- To work with a different model, change the
model
parameter. See a list of available models. - Modify the description of the image that should be generated.