API documentation
The OpenGM API is OpenAI-compatible and versioned under /v1. Existing OpenAI SDKs work by changing the base URL and using an OpenGM API key.
Base URL
https://developers.openlabsapp.com/api/public/v1Authentication
Create an API key in your dashboard under API keys. Keys start with ogm_, are shown only once, and can be revoked or set to expire at any time. Send the key as a bearer token on every request:
Authorization: Bearer ogm_…Keep keys in server-side secrets. Never embed them in browser or mobile app code.
Endpoints
GET /v1/models
Lists the available OpenGM models and their versions.
POST /v1/chat/completions
Creates a chat completion. Set "stream": true for a server-sent events stream of partial deltas.
POST /v1/completions
Creates a text completion for a single prompt.
GET /v1/usage
Returns token usage and request counts for the authenticated key.
Examples
curl
curl https://developers.openlabsapp.com/api/public/v1/chat/completions \
-H "Authorization: Bearer ogm_…" \
-H "Content-Type: application/json" \
-d '{
"model": "opengm",
"messages": [{ "role": "user", "content": "Hello!" }]
}'JavaScript (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENGM_API_KEY, // ogm_…
baseURL: "https://developers.openlabsapp.com/api/public/v1",
});
const completion = await client.chat.completions.create({
model: "opengm",
messages: [{ role: "user", content: "Hello!" }],
});Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENGM_API_KEY"], # ogm_…
base_url="https://developers.openlabsapp.com/api/public/v1",
)
completion = client.chat.completions.create(
model="opengm",
messages=[{"role": "user", "content": "Hello!"}],
)Streaming
Pass "stream": true to receive server-sent events. Each event is a JSON chunk with a choices[].delta payload; the stream ends with data: [DONE].
Errors
Errors return a JSON object with an error field containing message, type, and code:
{ "error": { "message": "Invalid API key.", "type": "authentication_error", "code": "invalid_api_key" } }| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_json | The request body is not valid JSON. |
| 401 | missing_api_key / invalid_api_key / key_revoked / key_expired | The bearer key is missing, unknown, revoked, or expired. |
| 403 | missing_scope | The key does not have the scope this endpoint requires. |
| 503 | backend_unavailable | The OpenGM backend is temporarily unreachable. Retry later. |