For the following example to work, save your API key to the NEBIUS_API_KEY environment variable. Request:
from openai import OpenAI
import os

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

completion = client.images.generate(
    model="stability-ai/sdxl",
    prompt="An elephant in a desert",
    response_format="b64_json",
    extra_body={
        "response_extension": "png",
        "width": 512,
        "height": 512,
        "num_inference_steps": 30,
        "seed": -1,
        "negative_prompt": "Giraffes, night sky"
    }
)

print(completion.to_json())
Save the image once you receive the link. Nebius AI Studio does not store the image from the provided link permanently.
For detailed field descriptions, see the API reference.