Sign up, get free credit, create a token
- Sign up and verify your email: you get $5 of free credit to start, while today's credits last.
- Add more by card any time from your dashboard.
- Create a token in the dashboard: open your dashboard, choose Create token, name it and pick an expiry (30, 60 or 90 days).
The dashboard shows the token once, as lines you can paste into your shell. Copy them then; you won't see it again.
export GRIDLINE_TOKEN="gla_..." # the token the dashboard shows once
export OPENAI_API_KEY="$GRIDLINE_TOKEN"
export OPENAI_BASE_URL="https://api.gridlinegpu.com/openai/v1"The token carries the read and routing:write scopes, which is what fine-tuning and batches need. You can revoke it from the dashboard at any time.
Or create a token with the CLI instead
Install the Gridline CLI and run gridline login. It prints a link and a code at once, waits up to 10 minutes while you approve it in your browser, then saves a private token, valid for 90 days, to ~/.config/gridline/python-token. An agent can run it for you. Export it as GRIDLINE_TOKEN:
python -m pip install -U gridlinegpu
gridline login
export GRIDLINE_TOKEN="$(cat ~/.config/gridline/python-token)"Set up the client
Gridline speaks OpenAI's API, so the OpenAI Python and Node SDKs work unchanged. Install the Python SDK if you don't have it:
python -m pip install openaiPoint the client at Gridline's base URL and give it your token:
import os, time
from openai import OpenAI
client = OpenAI(base_url="https://api.gridlinegpu.com/openai/v1", api_key=os.environ["GRIDLINE_TOKEN"])Then pick what you came to do:
- Fine-tune a model On your chat data, then download it.
- Run a batch A file of requests on a catalog model, such as
qwen3.5-9borbge-m3. - Do both Fine-tune, then run a batch on your
ft:model.
Fine-tune a model
Write your examples as JSONL in OpenAI's chat format, at least 11 of them. The job holds at least one out to measure the model and needs 10 of them to train on. Each line is one conversation in a messages list, and the assistant turns are what the model learns to write:
{"messages": [{"role": "system", "content": "You answer support tickets for Acme."}, {"role": "user", "content": "My invoice is wrong."}, {"role": "assistant", "content": "Sorry about that. Send the invoice number and I will check it."}]}Upload the file, create the job and wait for it to finish:
training = client.files.create(file=open("train.jsonl", "rb"), purpose="fine-tune")
job = client.fine_tuning.jobs.create(model="qwen3.5-9b", training_file=training.id)
print(job.gridline["quote"]) # creating the job started it; the quote shows what it can cost
while job.status not in ("succeeded", "failed", "cancelled"):
time.sleep(60)
job = client.fine_tuning.jobs.retrieve(job.id)
print(job.status, job.fine_tuned_model)You aren't charged for time spent waiting.
A job must finish within 5 hours.
The model is yours. Download it.
Your account trains one job at a time. An account can have 16 fine-tuning jobs and 64 batches open at once; a create over that answers 429 until one ends. There is no daily spend limit: you can use all the credit you have bought.
The job trains a bf16 LoRA adapter (the default). You don't choose a GPU or tune a recipe: Gridline runs it, and it trains QLoRA on smaller bases such as qwen2.5-0.5b-instruct. To show how much the model improved, the job measures eval loss before and after training and reports both in job.gridline["result"]. It measures on a validation file if you pass one, and otherwise on 5% of your training rows, held out.
When the job succeeds, job.fine_tuned_model names your model:
ft:qwen3.5-9b:o3f9a1c2d4e5:7b2c9e41a0d3The model is yours. Download it, two files, with your token:
curl https://api.gridlinegpu.com/openai/v1/gridline/adapters/ft:qwen3.5-9b:o3f9a1c2d4e5:7b2c9e41a0d3/files/adapter_model.safetensors \
-H "Authorization: Bearer $GRIDLINE_TOKEN" -o adapter_model.safetensors
curl https://api.gridlinegpu.com/openai/v1/gridline/adapters/ft:qwen3.5-9b:o3f9a1c2d4e5:7b2c9e41a0d3/files/adapter_config.json \
-H "Authorization: Bearer $GRIDLINE_TOKEN" -o adapter_config.jsonFine-tunes of qwen3-14b are download-only for now: they cannot run in a batch yet, and job.fine_tuned_model stays None. Download those by the name in job.gridline["fine_tuned_adapter"]["model"].
The fine-tuning guide covers the file rules, the settings you can change and how to delete a model.
Run a batch
Write one request per line, with body.model set to a catalog model:
{"custom_id": "t-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "qwen3.5-9b", "messages": [{"role": "user", "content": "My invoice is wrong."}], "max_tokens": 256}}Upload the file with purpose=batch, create the batch with the 24h completion window (or 72h, at the same price, for work that can wait: see the Batch API's completion window), and download the results when it finishes:
batch_input = client.files.create(file=open("requests.jsonl", "rb"), purpose="batch")
batch = client.batches.create(
input_file_id=batch_input.id,
endpoint="/v1/chat/completions",
completion_window="24h",
)
while batch.status not in ("completed", "failed", "expired", "cancelled"):
time.sleep(60)
batch = client.batches.retrieve(batch.id)
if batch.output_file_id:
open("results.jsonl", "wb").write(client.files.content(batch.output_file_id).content)
if batch.error_file_id:
open("errors.jsonl", "wb").write(client.files.content(batch.error_file_id).content)Each line of the results carries your custom_id and the usual response body, including usage. A request that failed on its own is in the error file, and the rest of the batch still completes.
For embeddings, use /v1/embeddings with bge-m3. The Batch API page has the details.
Run a batch on your model
Fine-tune a model, then run a batch with body.model set to your ft: model instead of a catalog one:
{"custom_id": "t-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "ft:qwen3.5-9b:o3f9a1c2d4e5:7b2c9e41a0d3", "messages": [{"role": "user", "content": "My invoice is wrong."}], "max_tokens": 256}}One batch can use up to 8 of your ft: models (fewer on some bases: Models), as long as they share a base model. Nobody else can use them: a batch from another account that names one gets model_not_found. The Batch API page has the rest of the rules.
What it costs
Fine-tuning and batch jobs are paid for from your prepaid credits. A fine-tuning job is charged for its training tokens times the number of epochs, at its base model's rate, and at least the per-job minimum. It is quoted when you create it, before it starts: creating the job starts it, and the same response carries the quote, with those tokens, the minimum and the most the job can cost. To see the quote without creating the job, send the same request with dry_run. When the job succeeds the charge is deducted from your credits, and it is never more than the quote. You can read the quote from job.gridline["quote"].
A batch is charged for the input and output tokens of the results it delivers, at its model's rates (a fine-tuned model's are its base's); embeddings are charged for their input tokens only. Credits are held when a batch is validated and settled when it ends.
If your credits can't cover a job, it fails with insufficient_quota before anything runs: a fine-tuning job when it starts, a batch when it is validated.
What a credit is worth, the credit packs and each model's rates are on the pricing page.
Hand it to your agent
Most code that calls Gridline will be written by an agent. So every page here can be read without a browser, and the API is the one your agent already knows.
- One index. llms.txt lists every public page and the docs, with the quickstart inline.
- Every page as Markdown. Add .md to a page's URL, or send Accept: text/markdown to the URL you already have.
- An API it already knows. Files, fine-tuning jobs and batches follow OpenAI's API. Change the base URL and the key.
The index is /llms.txt; this page is /docs.md. The agent quickstart, with the MCP server and the same loop over plain HTTP, is /docs/agents. To hand the whole job to a coding agent, paste this prompt into it and add what you want to do on the last line:
Help me use Gridline (https://gridlinegpu.com): managed fine-tuning and batch inference on open models, through an OpenAI-compatible API.
Before you write any code, read https://gridlinegpu.com/llms.txt and the docs it links. Every page there is also plain Markdown: add .md to its URL.
Rules:
- Base URL: https://api.gridlinegpu.com/openai/v1. The API key goes in the GRIDLINE_TOKEN environment variable. If it is not set, do not ask me to paste one: get one with no browser, as https://gridlinegpu.com/llms.txt says. Show me the terms and get my yes, then sign me up with my email (or log in with an emailed code if I already have an account). Gridline emails me a 6-digit code: read it from my inbox if you can, using only an email from the sender https://gridlinegpu.com/api/agent names, otherwise ask me for it. If I'd rather approve in a browser, run `pip install -U gridlinegpu && PYTHONUNBUFFERED=1 gridline login` instead (or the login tool of the Gridline MCP server, `npx -y @gridlinegpu/mcp`). Never print the key, paste it or commit it.
- Use the OpenAI client I already have. Do not add another SDK.
- Fine-tunes are quoted before they run, and every job is paid from my prepaid credits. Show me the quote, or the cost you expect, and wait for my yes before you create a fine-tune or a batch.
- Use only the models and parameters the docs list. If the docs do not cover something, say so instead of guessing.
What I want to do: