Browse all docs & guides
On this page
REFERENCE

Versioning & HTTP Contracts

OpenGen versions its public REST API under /v1 with an OpenAPI 3.1.0 schema at GET /openapi.json covering 24 endpoints across 6 tags and gateway liveness at GET /health. Unauthenticated catalog reads carry public CDN caching and wildcard CORS, while all authenticated, private, MCP, and error responses enforce Cache-Control no-store.

Reviewed 2026-12-03
AGENT PROMPT · PASTE INTO YOUR AGENT OR AUTO-READ
Verify OpenGen contract compatibility and HTTP behavior using https://opengen.dev/docs/versioning:
1. Inspect gateway liveness at GET https://opengen.dev/health and fetch the authoritative 24-endpoint OpenAPI 3.1.0 contract at GET https://opengen.dev/openapi.json (cached publicly with max-age=60, s-maxage=300 when unauthenticated).
2. Never hardcode unshipped third-party SDK imports — use raw HTTP (curl, fetch, httpx), Streamable HTTP MCP (https://opengen.dev/mcp or https://opengen.dev/mcp/readonly), or @opengen-dev/cli.
3. Always handle additive response fields gracefully, respect RateLimit / RateLimit-Policy / Retry-After headers, confirm budgets via POST https://opengen.dev/v1/pricing/estimate, and persist an Idempotency-Key before calling POST https://opengen.dev/v1/generations.
View raw .md ↗

API versioning and schema contract

OpenGen's Public Developer API is URL-versioned under **/v1 and documented by an authoritative OpenAPI 3.1.0 specification at GET /openapi.json** (current contract version 0.1.3, Apache-2.0 license).

  • Public surface size: 24 public endpoints grouped across 6 tags (models, pricing, generations, assets, webhooks, account). Browse them interactively at API Reference.
  • Gateway liveness: **GET /health** is unauthenticated, CORS-enabled, and served with Cache-Control: no-store, returning { "status": "ok", "database": <boolean>, "version": "0.1.3" }.
# Check liveness and current contract version
curl --fail-with-body -i "$OPENGEN_API_URL/health"

# Inspect the live OpenAPI 3.1.0 document (CDN-cached when unauthenticated)
curl --fail-with-body -I "$OPENGEN_API_URL/openapi.json"

Backwards compatibility policy

Additive (non-breaking) changes

Clients and AI agents should tolerate the following additive updates within /v1:

  • New exact model variants, new model series, new curated collections, and new regional deployments/routes in @media-router/catalog.
  • Optional response properties, new optional request parameters, new structuredError.code values, and new MCP tools or resources.
  • New dated pricing evidence entries or route status promotions from documented to live-verified.

Fixed execution identities and aliases

  • Exact variant IDs (provider/model) and canonical route IDs (deployment/model-slug) are stable execution contracts. Distinct derivatives are never merged under a shared ID.
  • Where a legacy split or provider-prefixed route ID is unified, OpenGen preserves resolution through the catalog routeAliases table (binding operation constraints when needed so an alias cannot silently execute a conflicting operation).

Deprecation and Sunset headers (RFC 8594)

Active /v1 endpoints omit Deprecation and Sunset headers. When an endpoint, parameter, or API version is scheduled for retirement, OpenGen follows RFC 8594 / RFC 9745 signaling and preserves these headers through the web edge proxy and CORS Access-Control-Expose-Headers:

  • **Deprecation**: RFC 9745 structured date (@<unix-timestamp>) or true once deprecation begins.
  • **Sunset**: RFC 8594 HTTP-date announcing the scheduled removal date (minimum 30 days advance notice for non-security breaking removals).
  • **Link**: Link: <https://opengen.dev/...>; rel="successor-version" pointing to the replacement endpoint or migration guide.

Recent /v1 surface consolidations

OpenGen recently consolidated its public surface around clean, minimal primitives:

  • **Compact GET /v1/models**: omits bulky generationProfiles by default (~25 KB); pass ?expand=schemas when needed or call GET /v1/models/{provider}/{model} / GET /v1/models/schema for single-model schemas.
  • Unified 4-route private assets: POST /v1/assets (multipart, base64, URL import, owned output reuse, presigned PUT), POST /v1/assets/complete, GET /v1/assets (list or ?key=), and DELETE /v1/assets (?key= or JSON { "key": "..." }), replacing legacy split asset action paths.
  • Per-request Ed25519 webhooks: ad-hoc webhookUrl + webhookEvents on POST /v1/generations verified via GET /.well-known/webhook-jwks.json, replacing legacy workspace webhook subscription tables.
  • Stateless cost estimation: dry-run POST /v1/pricing/estimate replacing legacy stateful quote flows.
  • Unified documentation URLs: all guides, client setup pages, and API references live under /docs/** (including /docs/guides/* and /docs/clients/*).

CDN caching, CORS, and rate-limit contracts

OpenGen enforces strict HTTP caching, CORS, and throttling invariants at the API edge:

SurfaceCache-ControlVaryCORS (Access-Control-Allow-Origin)
Unauthenticated 200 OK GET/HEAD on /openapi.json, /v1/models*, /v1/collections*, /v1/routes, /v1/pricingpublic, max-age=60, s-maxage=300Authorization, Cookie* (never with Access-Control-Allow-Credentials: true; 204 OPTIONS preflight max-age=600)
GET /.well-known/webhook-jwks.jsonpublic, max-age=3600—* (GET, HEAD, OPTIONS)
GET /healthno-store—* (GET, HEAD, OPTIONS)
Cookie-free POST /v1/pricing/estimatepublic, max-age=0, s-maxage=60 (unauth) / private, no-store (auth)—* (POST, OPTIONS)
/mcp and /mcp/readonlyno-store (JSON) / private, no-store, no-transform (SSE)Authorization* (POST, OPTIONS, never with credentials)
Any request with Authorization header or og_session cookie, all private /v1/generations*, /v1/assets*, /v1/balance, /v1/analytics, and all error responsesno-store (or private, no-store on /media/* & status streams)Authorization, Cookie where applicableNo wildcard CORS on private /v1/* or /auth/* routes
  • Rate-limit headers: /v1/* REST responses include standard RFC RateLimit and RateLimit-Policy headers, plus Retry-After on 429 responses (see Errors & Recovery).
  • Allowed & exposed CORS headers on public CORS routes:
  • Access-Control-Allow-Headers: Authorization, Content-Type, Accept, Idempotency-Key, Prefer, Mcp-Session-Id, Mcp-Protocol-Version, Last-Event-ID
  • Access-Control-Expose-Headers: Mcp-Session-Id, Mcp-Protocol-Version, X-Next-Cursor, Preference-Applied, WWW-Authenticate, Retry-After, RateLimit, RateLimit-Policy, Deprecation, Sunset, Link

Agentic Markdown discovery & llms.txt

Every public documentation, guide, client, provider, pricing, and model page on https://opengen.dev is natively machine-readable for AI coding agents and crawlers:

  • **Explicit .md twins & Accept: text/markdown**: Append .md to any /docs/**, /docs/clients/**, /docs/guides/**, /providers, /pricing, /[provider], /[provider]/[series], /about, or /contact URL — or send Accept: text/markdown (200 OK, Vary: Accept, Content-Type: text/markdown; charset=utf-8). Explicit .md twins emit Link: <canonical>; rel="canonical" and X-Robots-Tag: noindex, follow so search engines consolidate ranking signals on canonical HTML pages while AI agents fetch Markdown freely. Unknown paths return 404 Markdown linking key entry points.
  • Discovery indices:
  • /llms.txt — concise gateway summary and top links.
  • /docs/llms.txt — complete index of all /docs/**.md URLs.
  • /llms-full.txt — concatenated full Markdown documentation corpus.
  • /skill.md — installable agent skill instructions.
  • /sitemap.xml — unified XML sitemap with lastmod review dates.

SDK & CLI policy

Standalone third-party SDK distribution and language-specific framework adapters are intentionally deferred. OpenGen prioritizes:

  1. Crisp, self-contained raw HTTP examples (curl, standard fetch, Python httpx) backed by OpenAPI 3.1.0.
  2. Streamable HTTP MCP (/mcp and zero-auth /mcp/readonly).
  3. The published, zero-dependency portable CLI @opengen-dev/cli on npm (Node.js 22.12+).