Nebula Block API Quickstart: Your First Request in Python and cURL

Nebula Block API Quickstart: Your First Request in Python and cURL
Nebula Block API Quickstart: Your First Request in Python and cURL

You can go from a new account to a working model response in about five minutes. This guide takes you through each step: create an account, add credit, create an API key, and send your first request with cURL and Python. Everything here follows Nebula Block's Quickstart and Text Generation docs. Model names and limits are as of November 2026, and the catalog changes often.

What you need

  • A Nebula Block account and an email address you can confirm
  • At least $5 of credit
  • A terminal, and Python 3 if you want to follow the Python examples

One thing worth knowing up front: Nebula Block has two base URLs and one API key that works for both. https://inference.nebulablock.com/v1 runs models, which is what this guide uses. https://api.nebulablock.com/api/v1 manages instances, storage, keys and billing.

Step 1: Create an account

Sign up and confirm your email address. You can also sign in with Google.

Step 2: Add credit

Serverless inference is pay-as-you-go. A free (Tier 1) account has a daily request cap of 0 on most models, so in practice you need credit before your first call works. A $5 deposit moves you to Tier 2 and opens up the catalog. Add credit under Billing in the console. The Tiers and Rate Limits page shows exactly what each tier unlocks.

Step 3: Create an API key

Open API Keys in the console, create a key and copy it. Treat it like a password. Then store it as an environment variable so it never ends up in your code:

export NEBULA_API_KEY="sk-..."

Step 4: Send your first request with cURL

curl https://inference.nebulablock.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NEBULA_API_KEY" \
  -d '{
    "model": "deepseek-ai/DeepSeek-V3.2",
    "messages": [{"role": "user", "content": "What is an inference endpoint?"}]
  }'

If it works, you'll get a JSON response with the model's answer inside choices[0].message.content.

Step 5: Send the same request from Python

The Inference API is OpenAI-compatible, so you can use the OpenAI SDK by changing the base URL. Install it with pip install openai, then:

import os
from openai import OpenAI
client = OpenAI(
    base_url="https://inference.nebulablock.com/v1",
    api_key=os.environ["NEBULA_API_KEY"],
)
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3.2",
    messages=[{"role": "user", "content": "What is an inference endpoint?"}],
)
print(response.choices[0].message.content)

If you'd rather not install an SDK, plain requests works too:

import os
import requests
response = requests.post(
    "https://inference.nebulablock.com/v1/chat/completions",
    headers={
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['NEBULA_API_KEY']}",
    },
    json={
        "model": "deepseek-ai/DeepSeek-V3.2",
        "messages": [{"role": "user", "content": "What is an inference endpoint?"}],
    },
)
print(response.json()["choices"][0]["message"]["content"])

Read the response

A successful non-streaming response is a chat.completion object. The parts you'll use most:

  • choices[0].message.content: the model's reply
  • choices[0].finish_reason: why generation stopped (for example, stop)
  • usage: counts of prompt_tokens, completion_tokens and total_tokens

Log usage from the start. It's how you'll track cost per request as you scale up.

Try another model

Swap the model value for any ID in the Model Catalog. A few from the docs:

Model

Model ID

DeepSeek-V3.2

deepseek-ai/DeepSeek-V3.2

Llama 3.3 70B

meta-llama/Llama-3.3-70B-Instruct

Qwen3.5-Plus

Qwen/Qwen3.5-Plus

Gemini 3.7 Flash

gemini/gemini-3.7-flash

Model availability changes, so don't hard-code a list. Ask the API for the current one:

curl https://inference.nebulablock.com/v1/models \
  -H "Authorization: Bearer $NEBULA_API_KEY"

Tune the request

The chat endpoint takes the usual parameters:

  • max_tokens: the maximum number of tokens to generate
  • temperature: higher values give more varied output
  • top_p: another control for output diversity
  • stream: set to true to receive the response in chunks

To stream in Python:

stream = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3.2",
    messages=[{"role": "user", "content": "Write a haiku about GPUs."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
      

If something goes wrong

  • A 429 error. You've hit a limit: requests per minute, tokens per minute, or requests per day, either account-wide or for that specific model. The error message says which. Per-minute limits clear if you retry after a short wait. Daily counters reset at 00:00 UTC. The same model can be available at one tier and capped at zero at another, so upgrading your tier is what changes it.
  • A 402 error. Your credit balance can't cover the request. Add credit under Billing.
  • An authentication error. Check that the key is exported in your current shell and that the Authorization: Bearer header is spelled correctly.
  • "Model not found." Model IDs include a provider prefix, like deepseek-ai/DeepSeek-V3.2. List the models and copy the ID exactly.

Where to go next

Learn more at