Skip to main content
Every request authenticates with an API key in the Authorization header:

Create a key

Create keys in ZeroGen under Settings → API keys. Any member of an organization in the private beta can create one. ZeroGen shows the full key once, when you create it, so store it in your server’s secret store right away. When you create a key, you choose:
  • Live or test. A live key runs real generations and charges your organization. A test key runs the same requests on placeholder media at no charge.
  • Permissions. Give the key all scopes, read-only scopes, or a restricted set that you choose resource by resource.
  • Expiry. A key can expire after 1, 7, 30, or 90 days, after any number of days up to a year, or never. New keys default to 90 days, and Settings warns you two weeks before a key expires.
You can later rename a key, change its expiry, or change its permissions. Only a key’s owner can add access or extend its expiry. Organization admins can see every member’s keys, remove access from any of them, or make them expire sooner. Revoking a key takes effect on its next request.

Key prefixes

The prefixes let secret scanners recognize ZeroGen keys. ZeroGen stores each key’s mode with the key and doesn’t infer it from the prefix: a key sent with the other mode’s prefix is rejected.

What a key can do

A key belongs to the member who created it and acts as that member in the one organization it was created in. A key can never do more than its owner’s current role allows, and it stops working when its owner leaves the organization. Each request also needs the endpoint’s scope. Existing keys never gain new scopes automatically when ZeroGen adds them. GET /v1/me needs no scope. A generation or quote with an https URL input also needs uploads:create, because ZeroGen imports the URL into your Library. For details, see Uploads and URL inputs. A request without the scope it needs fails with 403 permission_denied, and details.scope names the missing scope.

Read your key’s access

GET /v1/me returns the calling key, its organization, and its owner:
scopes lists the scopes the key can use now: the ones it holds that its owner’s role still allows. expiresAt is null for a key that never expires. sandbox is null for a live key; for a test key, it names the API sandbox project.

Keep keys on your servers

API keys belong on servers. ZeroGen rejects any request that carries a browser Origin header with 403 permission_denied, and the API sends no CORS headers. Don’t embed a key in a web page, a mobile app, or any other code that runs on someone else’s device.

Authentication errors

For the full list of codes, see Errors.