# OpenGen Public Developer API Reference

> Machine-readable OpenAPI 3.1 reference covering all 24 Public Developer REST API endpoints across 6 tags. Full JSON specification: [https://opengen.dev/openapi.json](https://opengen.dev/openapi.json) · Interactive explorer: [https://opengen.dev/docs/api](https://opengen.dev/docs/api).

## Agent Prompt

```text
Fetch the live OpenAPI 3.1 specification at https://opengen.dev/openapi.json (summarized at https://opengen.dev/docs/api.md). Start with unauthenticated read-only discovery (GET https://opengen.dev/v1/models, GET https://opengen.dev/v1/models/{provider}/{model}, GET https://opengen.dev/v1/pricing, POST https://opengen.dev/v1/pricing/estimate). Confirm the exact modelId, routeId, and maxCostMicros budget with the user before sending Authorization: Bearer $OPENGEN_API_KEY and a persisted Idempotency-Key to POST https://opengen.dev/v1/generations. Honor RateLimit, RateLimit-Policy, and Retry-After headers on all /v1/* calls.
```

## Base URL, Authentication, Caching & Rate Limits

- **Base URL:** `https://opengen.dev` (override via `OPENGEN_API_URL` for self-hosted gateways)
- **OpenAPI 3.1 JSON:** [https://opengen.dev/openapi.json](https://opengen.dev/openapi.json)
- **Authentication:** Send `Authorization: Bearer <token>` using a scoped workspace API key (`/app/keys`) or OAuth 2.1 DCR + PKCE token. Never send raw upstream provider keys as OpenGen bearer tokens. Public catalog, pricing, schema, JWKS, and health endpoints require no authentication.
- **Caching & CORS:** Unauthenticated `200 OK` `GET`/`HEAD` catalog and `/openapi.json` responses return `Cache-Control: public, max-age=60, s-maxage=300` and `Access-Control-Allow-Origin: *`. Authenticated, cookie-bearing, private, and error responses always return `Cache-Control: no-store`.
- **Rate Limits:** `/v1/*` responses include standard RFC `RateLimit-Policy` and `RateLimit` headers so agents and clients can self-throttle, plus `Retry-After` on `429 Too Many Requests`.
- **Idempotency & Safety:** Persist a unique `Idempotency-Key` (1–200 chars) alongside the exact request before calling `POST /v1/generations`. Never invent a new key after a timeout or uncertain acceptance; recover read-only via `GET /v1/generations/lookup?idempotencyKey=...`.

## Endpoints by Tag (24 endpoints)

### Models & Catalog (`models`)

| Method | Path | Operation ID | Auth | Idempotency-Key | Summary |
| --- | --- | --- | --- | --- | --- |
| `GET` | `/v1/models` | `models.list` | Public (no auth) | — | List and search exact model variants (compact default; ?expand=schemas) |
| `GET` | `/v1/models/{provider}/{model}` | `models.get` | Public (no auth) | — | Inspect one exact model, its schemas, regional routes, and published pricing |
| `GET` | `/v1/models/schema` | `models.schema` | Public (no auth) | — | Read canonical JSON input schema and limits for a model and operation |
| `GET` | `/v1/collections` | `collections.list` | Public (no auth) | — | List curated capability collections across image, video, and audio |
| `GET` | `/v1/collections/{slug}` | `collections.get` | Public (no auth) | — | Inspect one capability collection and its member variants |
| `GET` | `/v1/routes` | `routes.list` | Public (no auth) | — | List regional serving routes with privacy and residency disclosures |

### Pricing & Cost Estimation (`pricing`)

| Method | Path | Operation ID | Auth | Idempotency-Key | Summary |
| --- | --- | --- | --- | --- | --- |
| `GET` | `/v1/pricing` | `pricing.list` | Public (no auth) | — | List source-linked published micro-USD tariffs per route |
| `POST` | `/v1/pricing/estimate` | `pricing.estimate` | Public (no auth) | — | Estimate generation cost and route eligibility without reserving credit |

### Generations & Jobs (`generations`)

| Method | Path | Operation ID | Auth | Idempotency-Key | Summary |
| --- | --- | --- | --- | --- | --- |
| `POST` | `/v1/generations` | `media.generate` | Bearer token / session | Required | Submit a billable generation once with an Idempotency-Key |
| `GET` | `/v1/generations` | `jobs.list` | Bearer token / session | — | List recent private generation jobs in the authenticated workspace |
| `GET` | `/v1/generations/lookup` | `jobs.lookup` | Bearer token / session | — | Recover an admitted job by its original Idempotency-Key |
| `GET` | `/v1/generations/{id}` | `jobs.get` | Bearer token / session | — | Read full job details and refresh temporary private output download links |
| `GET` | `/v1/generations/{id}/status` | `jobs.status` | Bearer token / session | — | Poll or long-poll compact job status (?afterRevision, ?waitMs) |
| `POST` | `/v1/generations/{id}/cancel` | `jobs.cancel` | Bearer token / session | — | Request cancellation of an in-flight generation job |
| `DELETE` | `/v1/generations/{id}/outputs` | `jobs.purgeOutputs` | Bearer token / session | — | Permanently purge archived output media bytes for a terminal job |
| `GET` | `/v1/generations/{id}/events` | `jobs.events` | Bearer token / session | — | Stream private job status updates via Server-Sent Events |

### Private Workspace Assets (`assets`)

| Method | Path | Operation ID | Auth | Idempotency-Key | Summary |
| --- | --- | --- | --- | --- | --- |
| `POST` | `/v1/assets` | `assets.create` | Bearer token / session | Optional (required for url/job_output) | Upload, import by HTTPS URL, reuse a job output, or prepare a presigned PUT |
| `POST` | `/v1/assets/complete` | `assets.complete` | Bearer token / session | — | Finalize a presigned single-PUT input asset upload |
| `GET` | `/v1/assets` | `assets.get` | Bearer token / session | — | List workspace-owned input assets or inspect one asset by key |
| `DELETE` | `/v1/assets` | `assets.delete` | Bearer token / session | — | Tombstone a workspace-owned input asset (?key= or JSON { key }) |

### Per-Request Ed25519 Webhooks (`webhooks`)

| Method | Path | Operation ID | Auth | Idempotency-Key | Summary |
| --- | --- | --- | --- | --- | --- |
| `GET` | `/.well-known/webhook-jwks.json` | `webhooks.jwks` | Public (no auth) | — | Read public Ed25519 verification keys for per-request ad-hoc webhooks |

### Account, Analytics & Health (`account`)

| Method | Path | Operation ID | Auth | Idempotency-Key | Summary |
| --- | --- | --- | --- | --- | --- |
| `GET` | `/v1/balance` | `balance.get` | Bearer token / session | — | Inspect available and reserved workspace credit in micro-USD |
| `GET` | `/v1/analytics` | `analytics.get` | Bearer token / session | — | Read bounded workspace spend, usage, and latency/reliability cohorts |
| `GET` | `/health` | `health` | Public (no auth) | — | Check gateway liveness |

## Quick Raw-HTTP Example

```bash
# 1. Inspect one exact model (schema, regional routes, privacy disclosures, pricing)
curl -fsS "https://opengen.dev/v1/models/openai/gpt-image-2"

# 2. Stateless dry-run cost estimate (no auth required for public catalog estimation)
curl -fsS -X POST "https://opengen.dev/v1/pricing/estimate" \
  -H "Content-Type: application/json" \
  -d '{"modelId":"openai/gpt-image-2","operation":"text-to-image","input":{"prompt":"A matte ceramic teapot on dark slate","resolution":"1K","quality":"low"},"billing":"managed"}'
```

## Related Documentation

- [Quickstart](https://opengen.dev/docs/quickstart.md)
- [Authentication & Scopes](https://opengen.dev/docs/authentication.md)
- [Generations & Safe Resume](https://opengen.dev/docs/generations.md)
- [Private Workspace Assets](https://opengen.dev/docs/assets.md)
- [Ed25519 Webhooks](https://opengen.dev/docs/webhooks.md)
- [Errors & Recovery](https://opengen.dev/docs/errors.md)
