Developers
WormGPT API
An OpenAI-compatible HTTP API for chat completions. Point any OpenAI client athttps://worm-gpt.com/v1and swap in your WormGPT key.
Overview
Introduction
The WormGPT API is OpenAI-compatible. Any client that speaks the OpenAI/v1/chat/completionsprotocol works — just change the base URL and API key.
- Base URL:
https://worm-gpt.com/v1 - Auth:
Authorization: Bearer wg_live_… - Content-Type:
application/json - Streaming: Server-Sent Events (SSE) with OpenAI-format chunks and a
[DONE]terminator.
Bearer tokens
Authentication
All requests must include your key in the Authorization header:
Authorization: Bearer wg_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXCreate and manage keys on the Developer page. Keys are shown once at creation — WormGPT stores only a hash. Revoke a key anytime; new requests will fail with 401 revoked_api_key.
Verify your key:
curl https://worm-gpt.com/v1/models \
-H "Authorization: Bearer $WORMGPT_API_KEY"Keep keys server-side
Never embed wg_live_… in browser code, mobile apps, or public repos. Proxy through your backend.
POST /v1/chat/completions
Chat completions
Generate a model reply from a list of messages. Returns a JSON completion, or an SSE stream when stream: true.
Request body
| Field | Type | Description |
|---|---|---|
| model | string | Model ID. Defaults to wormgpt-flash. See /v1/models. |
| messagesrequired | Message[] | Ordered conversation. Each item is { role: 'system'|'user'|'assistant', content: string }. 1–100 messages. |
| stream | boolean | If true, response is text/event-stream chunks. Defaults to false. |
| temperature | number | Sampling temperature between 0 and 2. |
| top_p | number | Nucleus sampling probability between 0 and 1. |
| max_tokens | integer | Cap on generated tokens. Up to 16,000. |
Example request
curl https://worm-gpt.com/v1/chat/completions \
-H "Authorization: Bearer $WORMGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wormgpt-flash",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain HTTPS in one sentence."}
]
}'Example response
{
"id": "chatcmpl-d6481db091ba4f5fab9897a0",
"object": "chat.completion",
"created": 1783120047,
"model": "wormgpt-flash",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "HTTPS encrypts data in transit between your browser and a server." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 18, "completion_tokens": 14, "total_tokens": 32 }
}stream: true
Streaming (SSE)
Set stream: true in the body. The response is text/event-stream: one JSON payload per data: line, terminated by data: [DONE]. The final chunk carries finish_reason and a usage object.
Streaming request
curl -N https://worm-gpt.com/v1/chat/completions \
-H "Authorization: Bearer $WORMGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wormgpt-flash",
"stream": true,
"messages": [{"role": "user", "content": "Write a haiku about firewalls."}]
}'Streaming response
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1783120061,"model":"wormgpt-flash","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1783120061,"model":"wormgpt-flash","choices":[{"index":0,"delta":{"content":"Firewalls "},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1783120061,"model":"wormgpt-flash","choices":[{"index":0,"delta":{"content":"stand guard..."},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1783120061,"model":"wormgpt-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":9,"completion_tokens":22,"total_tokens":31}}
data: [DONE]GET /v1/models
Models
List available models.
wormgpt-flash
Fast, general-purpose
Low-latency chat, code assistance, and everyday queries. The default model when you omit model.
wormgpt-pro
Deeper reasoning
Longer, more thorough responses for research, analysis, and multi-step reasoning. Higher token cost.
Example response
{
"object": "list",
"data": [
{ "id": "wormgpt-flash", "object": "model", "created": 1700000000, "owned_by": "wormgpt", "description": "Fast general-purpose model." },
{ "id": "wormgpt-pro", "object": "model", "created": 1700000000, "owned_by": "wormgpt", "description": "Higher-quality reasoning model." }
]
}Per-key and per-plan
Rate limits
Every response includes standard rate-limit headers so you can back off gracefully. Limits are enforced per API key, and monthly quotas are shared across all keys on your account.
| Plan | Requests / minute | Requests / month |
|---|---|---|
| Free | 60 | 1,000 |
| Pro (active subscription) | 600 | 100,000 |
Response headers
| Field | Type | Description |
|---|---|---|
| X-Plan | string | The plan applied to this request: free or pro. |
| X-RateLimit-Limit-Requests | integer | Per-minute request cap for the current plan. |
| X-RateLimit-Remaining-Requests | integer | Requests remaining in the current minute window. |
| X-RateLimit-Reset-Requests | integer | Seconds until the minute window resets. |
| X-RateLimit-Limit-Monthly | integer | Monthly request cap for the current plan. |
| X-RateLimit-Remaining-Monthly | integer | Requests remaining in the current calendar month (UTC). |
| Retry-After | integer | Sent on 429 responses. Seconds to wait before retrying. |
When you exceed a limit, the API returns 429 rate_limit_error with code: rpm (per-minute) or code: monthly. Use exponential backoff with jitter.
OpenAI-style error bodies
Errors
Errors return JSON in this shape:
{
"error": {
"message": "Invalid API key.",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null
}
}| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request / invalid_body / model_not_found | The request body is malformed or references a model that does not exist. |
| 401 | invalid_api_key / revoked_api_key | Missing, malformed, invalid, or revoked API key. |
| 402 | upstream_error | Upstream AI credit exhausted. Add credits or upgrade your plan. |
| 429 | rpm / monthly | Rate limit exceeded. Check X-RateLimit-* and Retry-After headers. |
| 500 | server_misconfigured | The API backend is missing required configuration. |
| 502 | upstream_error | Upstream model provider returned an error. Retry after a short backoff. |
Handle keys carefully
Security
- Keys are stored as SHA-256 hashes. Once created, the plaintext is never retrievable — save it immediately.
- Rotate keys regularly and revoke any key that may have been exposed.
- All requests must use HTTPS. Plaintext HTTP is rejected.
- Never call the API directly from a browser or mobile app with a production key. Proxy through your server.
- Scope keys per environment (e.g.
prod-backend,staging) so you can revoke one without disrupting others.
What's new
Changelog
Public API launch
- New endpoint:
POST /v1/chat/completions(OpenAI-compatible). - New endpoint:
GET /v1/models. - Server-Sent Events streaming for chat completions.
- Per-key rate limits and per-plan monthly quotas with
X-RateLimit-*headers. - Hashed API-key storage, one-time reveal, and revocation from the Developer page.
- Per-key daily usage logging (requests, prompt/completion tokens, errors).
