Skip to navigation

Authentication

Every request to Meadow carries one Meadow API key. The key starts with mdw_.

Next step: export the admin key you were given and list your projects.

export MEADOW_BASE_URL="https://api.usemeadow.ai"
export MEADOW_API_KEY="mdw_..."
curl -sS "$MEADOW_BASE_URL/v1/projects" \
-H "Authorization: Bearer $MEADOW_API_KEY"
{"data":[{"created_at":"2026-11-23T22:07:05.170Z","id":"prj_0000223e","name":"default","webhook_url":null}],"has_more":false,"object":"list"}

Samples on this page shorten IDs to eight characters after the prefix. Real IDs are longer.

Headers

Send the key in one of two headers:

HeaderUse it when
Authorization: Bearer mdw_...Default. OpenAI clients send this.
x-api-key: mdw_...Anthropic clients send this, so they work with only a base URL change.

You can send both headers if they carry the same key. Other schemes, such as Basic, are rejected.

On the Gemini route (/v1beta/models/... and POST /v1/models/{model}:generateContent), Meadow also reads the key from x-goog-api-key and from the key query parameter, where Gemini clients send it. Every copy you send must be the same key. Prefer the header: a query string can end up in request logs. See Gemini clients. Not on the hosted beta yet.

GET /health and GET /ready need no key.

What a bad key looks like

Every auth failure is a 401, and error.code and the message say which case you hit. On the model routes the same failure is written in the provider’s error format: see Errors on model routes.

curl -sS "$MEADOW_BASE_URL/v1/key"
{"error":{"code":"api_key_missing","message":"missing api key","type":"unauthorized"},"request_id":"req_0000c39c"}
Messageerror.codeCause
missing api keyapi_key_missingNeither header was sent.
invalid api keyapi_key_invalidNo key matches. Check for a truncated copy.
invalid authorization headerapi_key_header_invalidThe scheme is not Bearer, or the token is empty.
conflicting api key headersapi_key_header_invalidBoth headers were sent with different keys.
duplicate api key headersapi_key_header_invalidOne of the headers was sent twice.
api key has been revokedapi_key_revokedThe key was deleted. Create a new one.
api key has expiredapi_key_expiredThe key passed its expires_at. Create a new one.
api key is disabledapi_key_disabledThe key, or a key it was created from, was switched off with PATCH /v1/keys/{key_id}. Switch it on again, or create a new one.
the account is disabledaccount_disabledThe Meadow team switched the whole account off. Every key of the account gets this. Contact us.

Branch on error.code, not on the message.

More than 20 failed authentications in a minute from one address get a 429 until the minute ends. A request with a valid key is never throttled this way. See Errors.

Scopes

A key has one or more scopes. A request to a route outside the key’s scopes gets a 403.

ScopeRoutes
models/v1/chat/completions, /v1/responses, /v1/messages, GET /v1/models
sandboxes/v1/sandboxes and everything under it, /v1/images, /v1/build-contexts
admin/v1/projects, /v1/keys, /v1/provider-keys
curl -sS "$MEADOW_BASE_URL/v1/projects" \
-H "Authorization: Bearer $MODELS_ONLY_KEY"
{"error":{"code":"scope_missing","message":"key does not have admin scope","type":"forbidden"},"request_id":"req_0000c21d"}

The admin scope covers the whole account. An admin key in one project can read and change every project, every key, and every provider key in the account. Give admin only to keys that manage the account, and give workloads a key with models, sandboxes, or both.

Create a key

POST /v1/keys needs an admin key. The response contains secret once. Meadow stores only a hash of it and cannot show it again.

curl -sS -X POST "$MEADOW_BASE_URL/v1/keys" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project_id": "'"$PROJECT_ID"'",
"name": "ci-runner",
"scopes": ["models"],
"allowed_models": ["gemini-3.1-flash-lite-preview"],
"max_requests": 1000,
"max_tokens": 2000000,
"expires_at": "2026-12-31T00:00:00Z"
}'
{
"allowed_models": ["gemini-3.1-flash-lite-preview"],
"created_at": "2026-11-24T20:37:02.603Z",
"disabled": false,
"expires_at": "2026-12-31T00:00:00Z",
"id": "key_00006062",
"last4": "SkOk",
"last_used_at": null,
"limit_reset": null,
"limit_reset_at": null,
"max_requests": 1000,
"max_tokens": 2000000,
"name": "ci-runner",
"parent_key_id": "key_0000b694",
"project_id": "prj_0000742b",
"requests_remaining": 1000,
"requests_used": 0,
"revoked_at": null,
"scopes": ["models"],
"secret": "mdw_...",
"tokens_remaining": 2000000,
"tokens_used": 0
}
FieldRequiredMeaning
project_idyesThe project the key belongs to. It can be any project in the account.
namenoA label for your own use.
scopesnoAny of models, sandboxes, admin. Left out, the new key gets the parent key’s scopes among models and sandboxes. It gets admin only when you name it.
allowed_modelsnoModel IDs the key may call. Left out, the key may call any model. See Model and provider allowlists.
allowed_providersnoModel providers the key’s calls may go to. Left out, any. Not on the hosted beta yet.
allowed_sandbox_providersnoSandbox providers the key may create sandboxes on. Left out, any. Not on the hosted beta yet.
max_requestsnoTotal model requests the key may make.
max_tokensnoTotal tokens the key may use.
limitnoThe most US dollars the key may spend, on model calls and sandboxes. See Spend limits.
limit_actionnostop_sandboxes deletes the key’s running sandboxes when its limit is spent. Left out, they keep running. See Spend limits.
max_sandboxesnoThe most concurrent sandboxes among those made by this key and by keys created from it. See Sandboxes.
limit_resetnodaily, weekly or monthly. The max_requests, max_tokens and limit counters go back to zero at the start of each period, in UTC. Left out, the limits cover the key’s whole life.
expires_atnoRFC 3339 time. It must be in the future.

Any other field returns 400 with error.code parameter_unknown and the field in error.param.

The same call in Python:

import os
import requests
BASE = os.environ["MEADOW_BASE_URL"]
HEADERS = {"Authorization": f"Bearer {os.environ['MEADOW_API_KEY']}"}
resp = requests.post(
f"{BASE}/v1/keys",
headers=HEADERS,
json={
"project_id": os.environ["PROJECT_ID"],
"name": "nightly-evals",
"scopes": ["models"],
"max_requests": 500,
"expires_at": "2026-12-31T00:00:00Z",
},
timeout=30,
)
if resp.status_code != 201:
err = resp.json()["error"]
raise SystemExit(f"{resp.status_code} {err['type']}: {err['message']}")
key = resp.json()
print(key["id"], key["scopes"], "ends in", key["last4"])
secret = key["secret"] # shown once: store it now
key_0000647e ['models'] ends in o9ZE

And with the mdw CLI, which reads MEADOW_BASE_URL and MEADOW_API_KEY. mdw is sent to you during the beta. See Clients.

mdw keys create --project "$PROJECT_ID" --name cli-demo --scope models --json
{
"id": "key_0000a696",
"project_id": "prj_0000742b",
"name": "cli-demo",
"scopes": ["models"],
"allowed_models": null,
"expires_at": null,
"max_requests": null,
"max_tokens": null,
"last4": "MBIE",
"parent_key_id": "key_0000b694",
"limit_reset": "",
"limit_reset_at": null,
"disabled": false,
"requests_used": 0,
"tokens_used": 0,
"requests_remaining": null,
"tokens_remaining": null,
"last_used_at": null,
"created_at": "2026-11-24T20:37:14.045Z",
"revoked_at": null,
"secret": "mdw_..."
}

mdw prints the key in its own field order, and prints an empty limit_reset where the API returns null. The usage fields are explained under Read a key and its usage.

The key samples on this page were captured before 2026-11-28. A key object now also carries limit, usage, limit_remaining, limit_action and max_sandboxes. The table under Read a key and its usage says when each is null. A key created on the hosted beta on 2026-11-28 with "limit": 0.01 and "max_tokens": 1000 read back as:

{"created_at":"2026-11-28T06:47:06.598Z","disabled":false,"expires_at":null,"id":"key_0000af09","last4":"h7J8","last_used_at":"2026-11-28T06:47:07.175Z","limit":0.01,"limit_action":null,"limit_remaining":0.01,"limit_reset":null,"limit_reset_at":null,"max_requests":null,"max_sandboxes":null,"max_tokens":1000,"name":"docs-probe-spend","parent_key_id":"key_0000b694","project_id":"prj_0000223e","requests_remaining":null,"requests_used":0,"revoked_at":null,"scopes":["models","sandboxes"],"tokens_remaining":1000,"tokens_used":0,"usage":0}

mdw prints limit, usage, limit_remaining and limit_action, and not max_sandboxes.

Send an Idempotency-Key header with POST /v1/keys so a retry cannot create a second key. A retry by the same API key with the same Idempotency-Key and body within 24 hours returns the first response with Idempotent-Replayed: true and without secret, because Meadow keeps only a hash of a key. If you lost the first response, revoke that key by its id and create again with a new Idempotency-Key.

Child keys

A key created by another key is its child. The key that created it is its parent. A child can be equal to or narrower than its parent, never wider.

Parent hasChild must
A set of scopesName only scopes the parent holds.
allowed_modelsSet allowed_models, with only models from the parent’s list.
allowed_providers or allowed_sandbox_providersSet the same list, with only providers from the parent’s list. Not on the hosted beta yet.
max_requests, max_tokens or max_sandboxesSet the same limit, at or below the parent’s value.
limitNothing: the child spends from what the keys above it have left. A limit of its own must be at or below the parent’s.
expires_atSet expires_at, at or before the parent’s.

A parent with no restriction on a field puts no bound on that field in the child.

Breaking one of these rules returns 403. The message names the rule:

curl -sS -X POST "$MEADOW_BASE_URL/v1/keys" \
-H "Authorization: Bearer $TEAM_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{
"project_id": "'"$PROJECT_ID"'",
"scopes": ["models"],
"allowed_models": ["grok-4.7"],
"max_requests": 10,
"max_tokens": 1,
"expires_at": "2026-12-01T00:00:00Z"
}'
{"error":{"code":"key_grant_exceeds_parent","message":"max_requests 5000 is higher than the calling key's max_requests, 1000","param":"max_requests","type":"forbidden"},"request_id":"req_0000e736"}

Every one of these has error.code key_grant_exceeds_parent. error.param names the field, and the message gives the calling key’s own bound. The message above is from the server build after 2026-11-25.

paramThe message saysFix
scopesThe calling key does not hold the scope it names.Remove the scope, or create with a key that has it.
allowed_modelsThe calling key is not allowed the model it names, or allowed_models is required.Name only models from the calling key’s list. Leaving the field out is rejected when the calling key has a list.
allowed_providers, allowed_sandbox_providersThe calling key may not use the provider it names, or the list is required.Name only providers from the calling key’s list. Leaving the field out is rejected when the calling key has a list.
max_requestsThe value is higher than the calling key’s, or the field is required.Set max_requests at or below the calling key’s. Leaving it out is rejected when the calling key has a limit.
max_tokensThe same, for max_tokens.Set max_tokens at or below the calling key’s.
max_sandboxesThe same, for max_sandboxes.Set max_sandboxes at or below the calling key’s.
limitThe value is higher than the calling key’s limit.Set limit at or below the calling key’s, or leave it out.
expires_atThe value is later than the calling key’s expiry, or the field is required.Set expires_at at or before the calling key’s. Leaving it out is rejected when the calling key expires.

A child spends its parent’s limits

A child’s requests and tokens count against the child and against every key above it. Size a parent’s limits for all of its children together.

In this run the parent had max_requests: 3 and its child had max_requests: 2. The child made two calls and its third was rejected. The parent then made one call, and its next was rejected, because the child’s two calls had already counted against the parent’s three.

{"error":{"message":"api key max_requests limit reached: 2 of 2 requests used on this key","type":"invalid_request_error","param":null,"code":"key_request_limit_exceeded"},"request_id":"req_00006564"}

That is the child’s third call. The parent’s rejection reads 3 of 3 requests used on this key. The code is key_token_limit_exceeded for a token limit. When the limit that stopped a call belongs to a key above the caller, the message is api key max_tokens limit reached with no numbers.

A key that hits a limit stays at the limit until its counters reset, or until you raise the limit. Three things help:

  • Set limit_reset when you create the key, to daily, weekly or monthly. The counters then go back to zero at midnight UTC, on Monday at midnight UTC, or on the first of the month at midnight UTC. Without it the limits cover the key’s whole life. The name and the clock are OpenRouter’s. A child does not inherit its parent’s limit_reset, and a child’s reset never lifts a limit above it: its use counts against each key above it in that key’s own period.
  • Change max_requests, max_tokens, limit or limit_reset on a live key with PATCH /v1/keys/{key_id}. See Update or switch off a key.
  • Read what is left before a call is rejected. See Read a key and its usage.

A key with max_tokens or limit, or with a parent that has one, must send an output token limit on every model request (max_tokens, max_completion_tokens, or max_output_tokens, by format). Without one the request gets a 400. Token and request limits explains how both limits are counted.

Restrict a key to some models

allowed_models takes model IDs as GET /v1/models lists them, or <provider>/<model> to allow one model on one provider only. A call to a model outside the list gets a 403, and GET /v1/models shows that key only the models it may call. allowed_providers and allowed_sandbox_providers do the same for providers. Model and provider allowlists says how IDs match and how the lists hold child keys.

curl -sS "$MEADOW_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $WORKER_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "grok-4.7", "messages": [{"role": "user", "content": "hi"}], "max_tokens": 16}'
{"error":{"message":"model \"grok-4.7\" is not in this api key's allowed_models","type":"invalid_request_error","param":"model","code":"key_model_access_denied"},"request_id":"req_000080e7"}

Not on the hosted beta yet: until its next update this body has the message model is not permitted by this api key, param null and code forbidden.

Expiry

Set expires_at on any key that should end on its own, such as a key you pass into a sandbox or hand to a contractor’s CI job. After that time the key gets a 401 api key has expired. An expired key cannot be extended. Create a new one.

List keys

curl -sS "$MEADOW_BASE_URL/v1/keys?include_revoked=false&limit=2" \
-H "Authorization: Bearer $MEADOW_API_KEY"
{
"data": [
{"created_at":"2026-11-23T22:07:05.170Z","disabled":false,"expires_at":null,"id":"key_0000b694","last4":"oujI","last_used_at":"2026-11-24T00:18:21.833Z","limit_reset":null,"limit_reset_at":null,"max_requests":null,"max_tokens":null,"name":"root","parent_key_id":null,"project_id":"prj_0000223e","requests_remaining":null,"requests_used":52,"revoked_at":null,"scopes":["admin","models","sandboxes"],"tokens_remaining":null,"tokens_used":422794},
{"created_at":"2026-11-24T20:35:47.154Z","disabled":false,"expires_at":null,"id":"key_00009877","last4":"gmlc","last_used_at":null,"limit_reset":null,"limit_reset_at":null,"max_requests":null,"max_tokens":null,"name":"my-app","parent_key_id":"key_0000b694","project_id":"prj_0000223e","requests_remaining":null,"requests_used":0,"revoked_at":null,"scopes":["models"],"tokens_remaining":null,"tokens_used":0}
],
"has_more": true,
"next_cursor": "00000000000000000000000079a8...",
"object": "list"
}

The list covers every project in the account, oldest first. Query parameters: limit (default 50, at most 200), cursor (pass next_cursor from the last page), include_revoked and include_expired (both default true).

The list never shows a secret. has_more says whether another page follows. parent_key_id on a key names the key that created it.

Read a key and its usage

Three calls return a key with its limits and how much of them is used: GET /v1/keys (every key), GET /v1/keys/{key_id} (one key), and GET /v1/key (the key that makes the call). The first two need the admin scope. GET /v1/key works with any key, whatever its scopes, so a key you passed into a sandbox or an agent can check its own budget. OpenRouter has the same call.

curl -sS "$MEADOW_BASE_URL/v1/key" -H "Authorization: Bearer $WORKER_KEY"
{"allowed_models":["gemini-3.1-flash-lite-preview"],"created_at":"2026-11-24T20:38:05.494Z","disabled":false,"expires_at":"2026-12-01T00:00:00Z","id":"key_00000851","last4":"rufY","last_used_at":"2026-11-24T20:38:07.675Z","limit_reset":null,"limit_reset_at":null,"max_requests":2,"max_tokens":100000,"name":"child","parent_key_id":"key_0000a494","project_id":"prj_0000742b","requests_remaining":0,"requests_used":2,"revoked_at":null,"scopes":["models"],"tokens_remaining":99978,"tokens_used":22}

That key had made two model calls. The response is a key object:

FieldMeaning
requests_used, tokens_usedWhat counts against this key in its current period. It includes the use of every key created from this one, so do not add a parent and its children together. A key with no max_requests or max_tokens on itself or on a key above it is counted from the usage records: calls that were served, a few seconds behind.
requests_remaining, tokens_remainingThe limit minus the use, never below 0. Null when the key has no such limit. They look only at this key’s own limits: a limit on a key above it can reject a call first. Tokens held by calls in flight are not subtracted.
last_used_atWhen this key last authenticated a call of any kind, or when a model call was last counted against it or a key below it, whichever is later. It is written at most once a minute for each key, beside the call, and lands up to 2 seconds after the call that used the key. null for a key that was never used. Reading a key with itself (GET /v1/key) is a use of that key, and that same call can still show the earlier value.
limit_reset, limit_reset_atThe reset period, and the next time the counters go back to zero, in UTC. Both null when the key has no reset.
limit, max_sandboxes, limit_actionThe key’s own spend limit, sandbox cap and limit action, or null.
usageUS dollars charged to this key in its current period, the keys created from it included. Null when neither this key nor a key above it has a limit.
limit_remainingWhat the key can still spend: the least of limit minus usage over this key and every key above it, never below 0. Null when none of them has a limit. See Spend limits.
parent_key_idThe key that created this one. Null for a key no other key created.
disabledTrue when the key was switched off.

The counters cover the current period only. For use over time, read Usage and cost.

Update or switch off a key

PATCH /v1/keys/{key_id} changes a key’s name, max_requests, max_tokens, max_sandboxes, limit, limit_action, limit_reset and disabled, and its allowed_models, allowed_providers and allowed_sandbox_providers (not on the hosted beta yet). Only the fields you send change. Send null to clear a name, a limit, the reset or a list.

curl -sS -X PATCH "$MEADOW_BASE_URL/v1/keys/$KEY_ID" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"max_tokens": 500000, "limit_reset": "monthly"}'
{"created_at":"2026-11-24T20:38:27.940Z","disabled":false,"expires_at":null,"id":"key_0000e1ad","last4":"lJg8","last_used_at":null,"limit_reset":"monthly","limit_reset_at":"2026-12-01T00:00:00Z","max_requests":10,"max_tokens":500000,"name":"patch-child","parent_key_id":"key_0000e33e","project_id":"prj_0000742b","requests_remaining":10,"requests_used":0,"revoked_at":null,"scopes":["models"],"tokens_remaining":500000,"tokens_used":0}

The rules. Each was run on the hosted beta:

  • A new limit cannot be higher than the limit of the key that created this key. That returns 403 with error.code key_grant_exceeds_parent and the message max_tokens cannot be higher than the limit of the key that minted this key.
  • The usage counters do not change. A limit set below what is already used rejects the next call.
  • "disabled": true switches the key off without deleting anything. Every call with it, or with a key created from it at any depth, returns 401 api key is disabled until you send "disabled": false. It returns 409 with error.code last_admin_key when it would leave the account with no usable admin key.
  • Scopes, expires_at and the project cannot be changed. Sending one returns 400 unknown field in key update request. Create a new key for those.
  • A new list must stay inside the lists of the keys above this key and of the calling key, so a key cannot widen itself. That returns 403 key_grant_exceeds_parent. See Model and provider allowlists.
  • A revoked key cannot be updated. That returns 409 api key has been revoked and cannot be updated.

Rotate a key

POST /v1/keys/{key_id}/rotate gives a key a new secret. The key ID stays the same, and so do its project, scopes, limits, counters, expires_at and the keys created from it. Usage records keep the same key_id, so cost by key is unbroken. It needs the admin scope.

grace_period_seconds keeps the old secret working while you deploy the new one. The most is 604800, 7 days. Leave it out and the old secret stops at once.

# 1. Rotate, and keep the old secret for one hour.
curl -sS -X POST "$MEADOW_BASE_URL/v1/keys/$KEY_ID/rotate" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"grace_period_seconds": 3600}'
{"id":"key_00003a89","last4":"t3Qa","previous_secret_expires_at":"2026-11-28T11:00:00Z","secret":"mdw_REPLACED","scopes":["models","sandboxes"],"revoked_at":null}

The response above is cut to the fields that matter here and was not captured live. secret is shown once. previous_secret_expires_at says when the old secret stops. It is null on a key that has one secret.

What to know:

  • Both secrets are the same key. They count against the same limits, and a key that is revoked, switched off or expired is rejected through either one.
  • A key keeps one old secret. If you rotate again inside the grace period, the earlier old secret stops at once.
  • The grace period never runs past the key’s expires_at. Rotation does not move expires_at.
  • The route does not take Idempotency-Key. If you lose the response, rotate again. With a grace period the secret you still hold keeps working until you have the new one. With no grace period, rotate with another admin key.
  • An admin key may rotate itself. With no grace period, that response is the last one its old secret reads.
  • Each rotation is in the audit log as api_key.rotated. The entry never holds a secret.

To stop a key for good, revoke it instead.

Revoke a key

DELETE /v1/keys/{key_id} revokes a key at once and returns 204. Calling it again also returns 204. A revoked key stays in the list with revoked_at set.

Revoking a key revokes every key created from it, at any depth: the keys it created, the keys those created, and so on. parent_key_id on a key shows the tree, so list keys and read it before you revoke a key that created others. In a run on the hosted beta, a call with a child key returned 401 api key has been revoked right after its parent was revoked, and the child showed revoked_at in the list. Before 2026-11-24 the children stayed alive. A child that was live under a parent revoked before then is still live: revoke it by its own ID.

To stop a key for a while without revoking it, switch it off: see Update or switch off a key.

Two cases return 409 with error.code last_admin_key instead of revoking:

  • The key and the keys created from it hold every admin key of the account that is neither revoked nor expired. Create another admin key from a key that stays first.
  • For DELETE /v1/projects/{project_id}: the project holds every such admin key, or a limited key in it has a live child in another project. See Projects.

Lost keys

Meadow cannot show a secret again. If you lose a working key, create a new one with an admin key. If you lose every admin key, write to your Meadow contact: only Meadow can issue a new admin key for an account.

People in the dashboard

The Meadow dashboard signs people in and calls the API with the person’s session, not with a key. Not on the hosted beta yet. Each person has one role in the account: owner, admin, member or viewer (Read-only). A member sees and manages only the keys they created, and never creates an admin key. Model calls, sandbox creates and work inside a sandbox always need a key, so every dollar is charged to a key. A person may read GET /v1/models, GET /v1/sandboxes and GET /v1/images without x-meadow-project: the model list then covers every verified provider key of the account, and the two lists cover every project, each row naming its project_id. Your code keeps using keys, and nothing here changes for it. An owner or admin can restrict a project so a member or viewer sees it only after being added: see Restricted projects.

People ask for access on the Meadow website, which sends the form to createAccessRequest. It needs no key and no session. Meadow’s operators approve requests by hand. An owner invites people by email and sets their role. The invite page reads the invite from its link with getInviteLink, which also needs no credential and shows only the account name, the role, a masked address and the expiry. An invite lasts 7 days and is used once. The invited person signs in with that address, verified, and accepts the invite on its page with acceptInvite; signing in alone joins nothing. Every account keeps at least one owner. Removing a person revokes the keys they minted. A lower role revokes the keys the new role could not mint: admin keys below admin, every key for a viewer. A member or viewer also loses the keys they minted in a restricted project they can no longer see: when the project is restricted, when they are removed from its members, and when their role drops to member or viewer.

Operations for people: getMe, getMyPreferences, putMyPreferences, listMembers, updateMember, removeMember, listInvites, createInvite, revokeInvite, acceptInvite.

API reference

Operations on this page: createKey, listKeys, getCurrentKey, getKey, updateKey, revokeKey, rotateKey, listProjects.