AI API quickstart

Our API speaks the OpenAI format. If your code or app already works with OpenAI, change two things, the base URL and the key, and it runs on open models on our own hardware.

  1. 1. Create an accountSign up in a minute and get $5 of free credit. Already a customer? Sign in.
  2. 2. Make an API keyIn your account, open AI API and press Create key. Keys start with dgk_. Keep yours secret.
  3. 3. Point your code at usBase URL https://api.datagram.net/v1 and your key as a Bearer token. That's it.

Try it with curl

Paste your key into the first line, then run the rest in a terminal.

export DATAGRAM_API_KEY="dgk_your_key_here"

curl https://api.datagram.net/v1/chat/completions \
  -H "Authorization: Bearer $DATAGRAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemma4:26b-nvfp4",
    "messages": [{"role": "user", "content": "Explain what a datacenter does in one paragraph."}]
  }'

List every model your key can use: curl https://api.datagram.net/v1/models -H "Authorization: Bearer $DATAGRAM_API_KEY"

Python

Use OpenAI's official library: pip install openai

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.datagram.net/v1", api_key=os.environ["DATAGRAM_API_KEY"])

reply = client.chat.completions.create(
    model="gemma4:26b-nvfp4",
    messages=[{"role": "user", "content": "Write a haiku about servers."}],
    max_tokens=4096,
)
print(reply.choices[0].message.content)

# Streaming: print the answer as it's written
stream = client.chat.completions.create(
    model="gemma4:26b-nvfp4",
    messages=[{"role": "user", "content": "Count to five."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
print()

JavaScript / Node.js

Use OpenAI's official library: npm install openai

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.datagram.net/v1", apiKey: process.env.DATAGRAM_API_KEY });

const reply = await client.chat.completions.create({
  model: "gemma4:26b-nvfp4",
  messages: [{ role: "user", content: "Suggest three names for a coffee shop." }],
  max_tokens: 4096,
});
console.log(reply.choices[0].message.content);

Embeddings (search, RAG)

vectors = client.embeddings.create(model="bge-m3", input=["first text", "second text"])
print(len(vectors.data[0].embedding))  # numbers per text

Image generation

Make images from a text prompt. Sizes run from 256 to 1536 pixels per side, in multiples of 16.

Model nameGood forTimePrice
flux2-klein-4b (default)Fast, good photos and illustrationsabout 4 s$0.01 an image
z-image-turboFollows the prompt more literallyabout 12 s$0.01 an image
qwen-imageBest quality; the best at words and logosabout 1 minute$0.018 an image

All image models can misspell words, especially small text and names; check anything with lettering before you use it.

import base64
img = client.images.generate(model="flux2-klein-4b", prompt="A watercolor fox reading under an autumn tree",
                             size="1024x1024", n=1, response_format="b64_json")
open("fox.png", "wb").write(base64.b64decode(img.data[0].b64_json))

Images come back as base64 PNG only. We never store them, so there is no image URL. Add "seed": 42 to the request body (extra_body in the Python client) to get the same image again.

Use it in an app

Many chat apps, coding assistants and automation tools accept an "OpenAI-compatible" provider, also called a custom OpenAI endpoint. Examples are Chatbox, Open WebUI, the Continue and Cline extensions for VS Code, n8n and LangChain. In the app's settings, use:

Base URL / API host
https://api.datagram.net/v1
API key
your dgk_ key
Model
a name from the table below, for example gemma4:26b-nvfp4

Some apps want the address without /v1, or add /chat/completions themselves. If one complains, try the other form. Step-by-step setup for Claude Code, Ollama apps and more: AI API guides. Just want to chat? Use AI Chat, no setup needed.

Model names and prices

Use the name in the first column exactly as shown. Prices are dollars per million tokens. Full pricing, plans and credit

Model name (for your code)ModelTypeInputOutput
qwen3.5:0.8b-nvfp4 GeneralReads images Qwen3.5 0.8BGeneral$0.02$0.05
qwen3.5:2b-nvfp4 GeneralReads images Qwen3.5 2BGeneral$0.02$0.05
ministral-3:3b GeneralReads images Ministral 3 3BGeneral$0.05$0.10
qwen3.5:4b GeneralReads images Qwen3.5 4BGeneral$0.05$0.10
nemotron-3.5-bolt:e4b-nvfp4 GeneralReads images NVIDIA Nemotron 3.5 Bolt E4BGeneral$0.05$0.10
llama3.1 General Llama 3.1 8B (Built with Llama)General$0.05$0.10
granite4.1:8b General IBM Granite 4.1 8BGeneral$0.05$0.15
deepseek-r1:8b Reasoning DeepSeek R1 8B (distill)Reasoning$0.10$0.15
ministral-3:8b GeneralReads images Ministral 3 8BGeneral$0.10$0.15
qwen3.5:9b-nvfp4 GeneralReads images Qwen3.5 9BGeneral$0.10$0.15
gemma4:12b GeneralReads images Gemma 4 12BGeneral$0.05$0.15
gpt-oss:20b Reasoning gpt-oss 20BReasoning$0.05$0.20
gemma4:26b-nvfp4 GeneralReads images Gemma 4 26B-A4BGeneral$0.10$0.30
bge-m3 Embeddings BGE-M3 embeddingsEmbeddings$0.01–
qwen3-embedding:8b Embeddings Qwen3 Embedding 8BEmbeddings$0.10–

Good to know

Thinking models need room to answer

gpt-oss, Gemma 4, Qwen3.5/3.6/3.8 and DeepSeek R1 think before they answer, and the thinking counts toward max_tokens. With a small limit (say 100) the thinking can use all of it and the answer comes back empty. Use 2,048 to 4,096 or more. The thinking itself is returned in the message's reasoning field, separate from content.

Endpoints

GET /models, POST /chat/completions (with "stream": true for streaming), POST /completions, POST /embeddings and POST /images/generations, all under https://api.datagram.net/v1. Images: models marked with the picture icon in the table above (Gemma 4, Qwen3.5, Qwen3-VL and others) read images sent as OpenAI image_url parts with a base64 data: URL.

Cached input is cheaper

When a request starts with the same text as a recent one (a coding agent's instructions, a long document you keep asking about), the model reuses its earlier work. Those repeated input tokens cost 10% of the normal input price and show as "cached input" on your usage and invoices.

Limits

Each key allows 60 requests a minute and 4 at the same time by default. Need more? Ask us. Very large models load on first use, so the first request to a model can take a few extra seconds.

Errors you might see

401 missing or wrong key · 402 insufficient_quota out of credit, add credit · 404 model_not_found check the model name · 429 too many requests, wait and retry · 5xx a server problem on our side. Refused requests and errors are never charged.

Your data

Prompts, answers and generated images are never stored or used for training. We keep only counts for billing. How we handle your data

Create an account Get an API key Or just chat →