Skip to main content
For the following example to work, save your API key to the NEBIUS_API_KEY environment variable. Here is a sample JSON request body that includes all supported fields:
from openai import OpenAI

client = OpenAI(
    base_url="https://api.studio.nebius.com/v1/",
    api_key=os.environ.get("NEBIUS_API_KEY"),
)

for chunk in client.completions.create(
        model="meta-llama/Meta-Llama-3.1-70B-Instruct",
        prompt="Say my name",
        max_tokens=7,
        temperature=0,
        stream=True
):
    print(chunk.choices[0].text)
{
  "id": "cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe",
  "object": "text_completion",
  "created": 1690759111,
  "choices": [
    {
      "text": "Heisenberg",
      "index": 0,
      "logprobs": null,
      "finish_reason": null
    }
  ],
  "model": "meta-llama/Meta-Llama-3.1-70B-Instruct",
  "system_fingerprint": "fp_44709d6aaa"
}
For detailed field descriptions, see the API reference.