Nebius Python SDK

0.3.55 · active · verified Sat Apr 11

Nebius provides an AI Cloud platform with a Python SDK (nebius) to interact with its various services, including AI Studio for large language models and embeddings, Compute for virtual machines and GPUs, and Object Storage. The SDKs are built on gRPC and Protocol Buffers, offering programmatic access to the Nebius AI Cloud. As of January 24, 2025, the Python SDKs are generally available. The project maintains an active development pace with frequent updates, as indicated by its current version 0.3.55.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to interact with Nebius AI Studio using its OpenAI-compatible API. You will need an API key from Nebius AI Studio, preferably set as an environment variable (NEBIUS_API_KEY). The `openai` Python library is used, with the `base_url` configured to point to the Nebius AI Studio endpoint. Replace `Qwen/Qwen3-30B-A3B-fast` with an actual model available in your Nebius AI Studio account.

import os
from openai import OpenAI

# Ensure NEBIUS_API_KEY is set in your environment variables
# Example: export NEBIUS_API_KEY='YOUR_API_KEY'
# You can obtain an API key from Nebius AI Studio.
nebius_api_key = os.environ.get('NEBIUS_API_KEY', 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

if not nebius_api_key:
    print("Error: NEBIUS_API_KEY environment variable not set.")
    print("Please get your API key from Nebius AI Studio and set it.")
else:
    try:
        client = OpenAI(
            base_url="https://api.tokenfactory.nebius.com/v1/", # Or your specific Nebius AI Studio endpoint
            api_key=nebius_api_key,
        )

        chat_completion = client.chat.completions.create(
            model="Qwen/Qwen3-30B-A3B-fast", # Replace with an available model from Nebius AI Studio
            messages=[
                {"role": "user", "content": "Hello, what is your name?"}
            ]
        )
        print(chat_completion.choices[0].message.content)
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →