Documentation

    Getting started with inference

    Coding agents

    Getting started with workflows

Getting started with inference

This guide takes you from a fresh account to your first model response. Pick the Playground (about a minute), the OpenAI-compatible API (about five minutes), or a coding agent like OpenCode — they all use the same models and the same credit.
New accounts include $1 of inference credit. No credit card required.

1. Try the Playground

  1. Sign in at graphn.ai and select a workspace (or create one).
  2. Open Playground in the sidebar.
  3. Pick a model. DeepSeek V4.1 Flash is a strong general-purpose choice; Qwen3 80B is the platform's default chat model.
  4. Type a prompt and send it. The answer streams in, and the panel shows the prompt and completion token counts. The charge for the request is in Logs.

2. Create an API key

In the app, open API keys at the bottom of the sidebar and create a key. Keys start with gn_ and belong to one workspace; requests made with a key are billed to that workspace's organization.
Export it so the examples below can read it:
bash
export GRAPHN_API_KEY=gn_...

3. Send a request

Base URL: https://model.graphn.ai/v1

curl

bash
curl https://model.graphn.ai/v1/chat/completions \
  -H "Authorization: Bearer $GRAPHN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-80b",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
A successful response is an OpenAI-style JSON object; the reply is in choices[0].message.content and token counts are in usage.

Python

Install the SDK with pip install openai, then:
python
import os

from openai import OpenAI

client = OpenAI(base_url="https://model.graphn.ai/v1", api_key=os.environ["GRAPHN_API_KEY"])

response = client.chat.completions.create(
    model="qwen3-80b",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

TypeScript

Install the SDK with npm install openai, then:
typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://model.graphn.ai/v1",
  apiKey: process.env.GRAPHN_API_KEY,
});

const response = await client.chat.completions.create({
  model: "qwen3-80b",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);

Vercel AI SDK

Install the packages with npm install ai @ai-sdk/openai-compatible, then:
typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const graphn = createOpenAICompatible({
  name: "graphn",
  baseURL: "https://model.graphn.ai/v1",
  apiKey: process.env.GRAPHN_API_KEY,
  includeUsage: true,
  supportsStructuredOutputs: true,
});

const { text } = await generateText({
  model: graphn("qwen3-80b"),
  prompt: "Hello",
});
console.log(text);
streamText and tool calling work with every built-in chat model. Output.object requires a model with structured-output support; see Models. includeUsage returns token counts on streamed replies, and supportsStructuredOutputs sends your schema as JSON Schema. Model-specific parameters go under providerOptions.graphn, such as { graphn: { reasoningEffort: "low" } } or { graphn: { chat_template_kwargs: { enable_thinking: false } } }.

CLI

bash
brew tap voltagepark/graphn && brew install graphn
graphn login
graphn model chat qwen3-80b -m "Hello"
The command prints the model's reply in the terminal. graphn model chat without -m starts an interactive session. See Developing with agents for other install options.

4. Pick a model

The model field takes the model's callable name, such as qwen3-80b, deepseek-v4.1-flash, or glm-5.3. Models lists every built-in model with its context window, and each links to a page with pricing. To list the models your key can call:
bash
curl https://model.graphn.ai/v1/models \
  -H "Authorization: Bearer $GRAPHN_API_KEY"
Models you import or deploy yourself are called the same way, as imported:<id> or custom:<id>. The Playground in the app runs any of them and shows the matching request in its Code view.
Thinking models: DeepSeek V4.1 Flash can return its reasoning in reasoning_content, alongside the answer in content. Qwen3 80B is instruct-only and never emits a separate reasoning field. Reasoning counts toward max_tokens, so allow a few thousand output tokens — a thinking model given a small budget can return empty content with finish_reason: "length". To turn thinking off, pass chat_template_kwargs: {"enable_thinking": false} (see Parameters beyond the OpenAI SDK).

5. Use a coding agent

OpenCode and other OpenAI-compatible clients can use GraphN as a provider. Every client needs the same three values: the base URL https://model.graphn.ai/v1, your workspace API key, and a callable model name.
This section covers OpenCode. For Claude Code, Codex and Cursor, which each speak a different API, see Coding agents.

OpenCode

  1. Create an API key (see Step 2) and export it:
    bash
    export GRAPHN_API_KEY="gn_..."
  2. Add GraphN to ~/.config/opencode/opencode.json or opencode.jsonc (or a project-level opencode.json):
    json
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "graphn": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "GraphN",
          "options": {
            "baseURL": "https://model.graphn.ai/v1",
            "apiKey": "{env:GRAPHN_API_KEY}"
          },
          "models": {
            "deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash" },
            "qwen3-80b": { "name": "Qwen3 80B" },
            "glm-5.3": {
              "name": "GLM-5.3",
              "options": { "reasoningEffort": "high" }
            }
          }
        }
      }
    }
  3. Run opencode, then /models, and pick GraphN → DeepSeek V4.1 Flash (or another model with tool calling).
    The keys in models must match the callable model names from the models reference; add or remove entries to match the models you want in the picker. Keep reasoningEffort on GLM-5.3: without it, GLM-5.3 can think until it hits the output limit, and OpenCode ends the session without a reply.
See the OpenCode custom provider docs for the full config reference.

Other tools

Any client that accepts an OpenAI-compatible base URL works the same way: set the base URL to https://model.graphn.ai/v1, use your gn_ key, and the model's callable name. For the GraphN CLI and agent workflows, see Developing with agents.

Streaming

Set stream to receive the reply as server-sent events, one chunk at a time:
python
stream = client.chat.completions.create(
    model="qwen3-80b",
    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="", flush=True)

Images

Vision models take OpenAI-style content parts. An image can be an https URL or a data: URL:
python
response = client.chat.completions.create(
    model="qwen3-vl",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is in this image?"},
                {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}},
            ],
        }
    ],
)

Parameters beyond the OpenAI SDK

Some models take parameters the OpenAI SDK does not define, such as top_k or a thinking switch. In Python, pass them through extra_body:
python
response = client.chat.completions.create(
    model="qwen3.8-27b",
    messages=[{"role": "user", "content": "Hello"}],
    extra_body={"top_k": 20, "chat_template_kwargs": {"enable_thinking": False}},
)

Troubleshooting

Scroll horizontally to compare
StatusWhat to do
401The key is missing, revoked, or malformed. Check the key and export it again.
402The organization is out of credit. Add credit under Billing.
404No model by that name is available to this workspace. Use a name from Models.
429Too many requests. Retry with backoff.
503A model you deployed is scaled to zero and is waking up. Wait, then retry.

Next steps

Next

Coding agents