Weightship
API reference

Calling models

The API follows OpenAI's chat completions format, so existing SDKs and tools work by changing the base URL and key.

Authentication

Create a key in Dashboard → API keys and send it as a bearer token. Requests are billed to the account that owns the key, from prepaid credits.

Authorization: Bearer ws_...

Endpoints

MethodPathWhat it does
POST/v1/chat/completionsChat completion. Supports stream, max_tokens, temperature, top_p, stop, seed and response_format.
POST/v1/completionsPlain text completion.
GET/v1/modelsPublic models with their prices and current status.
GET/v1/usage?days=30Your spend by day and model, your balance, and this key's spend this month.
curl https://api.weightship.com/v1/chat/completions \
  -H "Authorization: Bearer $WEIGHTSHIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "alice/legal-qwen-8b", "stream": true,
       "messages": [{"role": "user", "content": "Summarise clause 4"}]}'

Structured outputs

Add response_format and the model can only produce text of that shape: every token is checked against the format as it's generated, so a reply can't come back with a missing field, an extra sentence or a code fence. It works the same as OpenAI's parameter, with a regex option on top.

response_formatWhat you get
{"type": "json_schema", "json_schema": {"schema": {...}}}JSON matching your schema exactly: the fields you list, the types and allowed values you set. The best choice for apps.
{"type": "json_object"}Any JSON object. Say in your prompt which fields you want, or the model may answer with an empty object.
{"type": "regex", "regex": "(yes|no)"}Text matching a pattern, for labels, codes and short fixed answers.
curl https://api.weightship.com/v1/chat/completions   -H "Authorization: Bearer $WEIGHTSHIP_API_KEY"   -H "Content-Type: application/json"   -d '{"model": "you/support-bot",
       "messages": [{"role": "user", "content": "Can I return an opened blender?"}],
       "response_format": {"type": "json_schema", "json_schema": {"schema": {
         "type": "object",
         "properties": {"answer": {"type": "string"}, "confidence": {"type": "string", "enum": ["low", "medium", "high"]}},
         "required": ["answer", "confidence"], "additionalProperties": false}}}}'

The format fixes the shape, not the content: a small model can still give a wrong answer in perfect JSON. Set max_tokens high enough for the whole object, because a reply cut off by the limit ends mid-JSON (its finish_reason is length). The same schema can be a rule when you train, and then the model learns the format too.

Billing behaviour

Rulebench API and MCP server

Test a system prompt's rules from code or from an agent. Part of Rulebench Pro; model calls are paid from credit, or from a connected provider key when you pass its key_id. Setup for Claude Code, Cursor and GitHub Actions is on the agents page.

MethodPathWhat it does
POST/v1/rulebench/auditsBody {prompt, models?, messages?, name?, key_id?, wait?}. Reads the rules, writes the tests, starts one run per model. wait (seconds, up to 55) waits for results.
GET/v1/rulebench/audits/:id?wait=50Scores per model, per-rule results and the failing replies. status is done when every run has finished.
POST/v1/rulebench/audits/:id/retestSame tests and models; with prompt it tests the new prompt as a revision, without it reruns the original.
POST/v1/rulebench/audits/:id/fixA revised prompt that fixes what broke, with a list of changes.
PUT/v1/rulebench/audits/:id/scheduleBody {schedule: "daily" | "weekly" | null}: monitoring with email alerts.
POST/mcpThe MCP server (streamable HTTP), with the same API key as a bearer token.

Errors

StatusCodeMeaning
401invalid_api_keyMissing, wrong or revoked key.
402insufficient_quotaBalance too low. Add credits.
400bad_response_formatThe response_format isn't usable: an unknown type, a schema that isn't an object, or a pattern that doesn't compile.
404model_not_foundNo such model, or it's private to someone else.
429rate_limit_errorToo many requests on this key. Back off and retry.
429insufficient_quota · key_limit_reachedThis key reached its monthly spend limit.
503pool_startingThe model's GPU was asleep and is starting. Retry in about a minute (see Retry-After). Nothing is charged.
503pool_unavailableThe GPU pool is starting or unreachable. Retry with backoff.
Live · just you here