Skip to navigation

Quickstart

Make your first model call with your own provider key. Then, if you need a sandbox, create one, run a command, and delete it.

For the model call, you need:

  • The base URL and admin key you received when you joined the beta.
  • A Google Gemini API key.
  • curl.

The optional sandbox example uses a Daytona API key. The Python example runs both workflows and needs Python 3.9 or newer and the requests package.

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

1. Set your Meadow API key

export MEADOW_BASE_URL="https://api.usemeadow.ai"
export MEADOW_API_KEY="mdw_..."

Your account starts with one project, and your admin key belongs to it.

2. Store a model provider key

Store the Gemini API key Meadow will use for the model call.

export GOOGLE_API_KEY="<your Gemini API key>"
curl -sS -X PUT "$MEADOW_BASE_URL/v1/provider-keys/google" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"credentials": {"api_key": "'"$GOOGLE_API_KEY"'"}}'
{"created_at":"2026-11-24T20:27:02.937Z","last4":"a1B2","project_ids":null,"provider":"google","verified_at":"2026-11-24T20:35:20.314Z"}

Meadow checks the key with the provider before saving it, encrypts it, and never returns it. last4 identifies the stored key.

Other providers require different credential fields. See Provider keys.

3. Make a model call

Send the request in the OpenAI Chat Completions format, with your Meadow API key:

curl -sS "$MEADOW_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-lite-preview",
"messages": [{"role": "user", "content": "Say hello in five words."}],
"max_tokens": 32
}'
{"choices":[{"finish_reason":"stop","index":0,"message":{"content":"Hello there, how are you?","extra_content":{"google":{"thought_signature":"EqkBCqYB..."}},"role":"assistant"}}],"created":1795552521,"id":"CPUFa7Kd...","model":"gemini-3.1-flash-lite-preview","object":"chat.completion","usage":{"completion_tokens":7,"prompt_tokens":7,"total_tokens":14}}

The response body is the provider’s, unchanged. Three response headers say who served it. Add -i to see them:

x-meadow-attempts: 1
x-meadow-model: gemini-3.1-flash-lite-preview
x-meadow-provider: google

Meadow also takes the OpenAI Responses and Anthropic Messages formats. See Models. To point an OpenAI or Anthropic SDK at Meadow, see Use your existing tools.

4. Run a command in a sandbox (optional)

You need a stored sandbox provider key for this example. Store your Daytona API key:

export DAYTONA_API_KEY="<your Daytona API key>"
curl -sS -X PUT "$MEADOW_BASE_URL/v1/provider-keys/daytona" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"credentials": {"api_key": "'"$DAYTONA_API_KEY"'"}}'
{"created_at":"2026-11-24T20:34:43.030Z","last4":"c3D4","project_ids":null,"provider":"daytona","verified_at":"2026-11-24T20:35:20.596Z"}

This response was captured before 2026-11-28. Since then, the daytona response also carries sandbox_health, which reports whether recent sandbox creates failed. See Provider keys.

Create a sandbox and wait for it to run:

curl -sS -X POST "$MEADOW_BASE_URL/v1/sandboxes?wait=true" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "python:3.12-slim", "timeout_seconds": 600}'
{
"attempts": [{"duration_ms": 1425, "outcome": "served", "provider": "daytona"}],
"created_at": "2026-11-24T20:35:42.556Z",
"expires_at": "2026-11-24T20:45:44.154Z",
"failure_reason": null,
"id": "sbx_00001f4e",
"labels": {},
"name": null,
"network": {"allow_cidrs": [], "allow_domains": [], "block_all": false},
"ports": [],
"project_id": "prj_0000223e",
"provider": "daytona",
"provider_sandbox_id": "0000e093",
"resources": {"cpu": 2, "memory_mb": 4096},
"ssh": false,
"started_at": "2026-11-24T20:35:44.154Z",
"status": "running",
"terminated_at": null
}

This response was captured on 2026-11-24, before each attempt carried reason, started_at and finished_at, which it does now. GET /v1/sandboxes/{sandbox_id} also returns a cost object: see Usage and cost.

The same create, the command and the delete were run again on the hosted beta on 2026-11-28, served by Modal: 202 with running, exit code 0 with Python 3.12.15, then 202 on the delete and 409 sandbox is not running for a command sent after it.

Read status. The call answers 202 whether the sandbox is running or failed. A failed sandbox says why in failure_reason and attempts. The usual cause is a misspelled image name.

Run a command, using the id from the response:

export SANDBOX="sbx_..."
curl -sS -X POST "$MEADOW_BASE_URL/v1/sandboxes/$SANDBOX/exec" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "python --version && echo hello from the sandbox"}'
{"exit_code":0,"stderr":"","stdout":"Python 3.12.16\nhello from the sandbox\n","timed_out":false}

Delete the sandbox when you are done. It runs in your provider account and the provider bills you for it. timeout_seconds ends it after ten minutes if you forget.

curl -sS -X DELETE "$MEADOW_BASE_URL/v1/sandboxes/$SANDBOX" \
-H "Authorization: Bearer $MEADOW_API_KEY" -w '%{http_code}\n'
204

A command sent to a sandbox that is not running returns a 409:

{"error":{"code":"conflict","message":"sandbox is not running","type":"conflict"},"request_id":"req_0000903c"}

Every error body carries a request_id. Send it to support when you report a failed call.

If you stored no key for a sandbox provider, the create returns a 422 with the type no_provider_key and the message no usable sandbox provider key stored for allowed providers. Fix: store a daytona or modal key as shown at the start of this step.

5. Create a key for your code

The admin key manages your whole account. Keep it out of your application. Create a key that holds only the scopes the application needs. List your projects and copy the project ID for the application key:

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","max_sandboxes":null,"name":"default","webhook_url":null}],"has_more":false,"object":"list"}
export PROJECT_ID="prj_..."
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": "my-app", "scopes": ["models"]}'
{"created_at":"2026-11-28T07:48:21.842Z","disabled":false,"expires_at":null,"id":"key_0000f1f0","last4":"e5F6","last_used_at":null,"limit":null,"limit_action":null,"limit_remaining":null,"limit_reset":null,"limit_reset_at":null,"max_requests":null,"max_sandboxes":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"],"secret":"mdw_...","tokens_remaining":null,"tokens_used":0,"usage":null}

secret is shown once. Store it now.

A key works only on the routes its scopes cover. This key has models, so a sandbox call with it returns a 403:

export APP_KEY="mdw_..."
curl -sS "$MEADOW_BASE_URL/v1/sandboxes" \
-H "Authorization: Bearer $APP_KEY"
{"error":{"code":"scope_missing","message":"key does not have sandboxes scope","type":"forbidden"},"request_id":"req_0000ff69"}

Fix: create a key with "scopes": ["models", "sandboxes"], or use a key that has the scope. A key’s scopes cannot be changed after it is created. Authentication lists the routes each scope covers.

The same steps in Python

This script stores both provider keys, makes the model call, and runs the sandbox example. Set all four environment variables shown above before running it.

import os
import requests
BASE = os.environ["MEADOW_BASE_URL"]
HEADERS = {"Authorization": f"Bearer {os.environ['MEADOW_API_KEY']}"}
def call(method, path, **kwargs):
resp = requests.request(method, f"{BASE}{path}", headers=HEADERS, timeout=330, **kwargs)
if not resp.ok:
raise SystemExit(f"{method} {path}: {resp.status_code} {resp.text}")
return resp
# Step 2: store your vendor keys.
for provider, variable in [("google", "GOOGLE_API_KEY"), ("daytona", "DAYTONA_API_KEY")]:
stored = call("PUT", f"/v1/provider-keys/{provider}", json={"credentials": {"api_key": os.environ[variable]}})
print("stored", stored.json()["provider"])
# Step 3: make a model call.
reply = call(
"POST",
"/v1/chat/completions",
json={
"model": "gemini-3.1-flash-lite-preview",
"messages": [{"role": "user", "content": "Say hello in five words."}],
"max_tokens": 32,
},
)
print(reply.json()["choices"][0]["message"]["content"])
print("served by", reply.headers["x-meadow-provider"], "in", reply.headers["x-meadow-attempts"], "attempt(s)")
# Step 4: create a sandbox, run a command, delete the sandbox.
sandbox = call(
"POST",
"/v1/sandboxes",
params={"wait": "true"},
json={"image": "python:3.12-slim", "timeout_seconds": 600},
).json()
try:
if sandbox["status"] != "running":
raise SystemExit(f"sandbox is {sandbox['status']}: {sandbox['failure_reason']} {sandbox['attempts']}")
print("sandbox running on", sandbox["provider"])
result = call(
"POST",
f"/v1/sandboxes/{sandbox['id']}/exec",
json={"command": "python --version && echo hello from the sandbox"},
).json()
print(result["exit_code"], result["stdout"], end="")
finally:
deleted = call("DELETE", f"/v1/sandboxes/{sandbox['id']}")
print("delete returned", deleted.status_code)
stored google
stored daytona
Hello, it is nice meeting.
served by google in 1 attempt(s)
sandbox running on daytona
0 Python 3.12.16
hello from the sandbox
delete returned 204

On any error the script stops and prints the status and the error body. A delete can also return 202 when the provider is slow. Both mean the sandbox is ending.

If a step fails

Authentication

If the key is missing you get a 401:

{"error":{"code":"api_key_missing","message":"missing api key","type":"unauthorized"},"request_id":"req_0000c7e0"}

Fix: check that MEADOW_API_KEY is set in this shell. A mistyped key returns invalid api key. Authentication lists every case.

Missing model provider key

If no stored key can serve the model, for example because you skipped step 2, you get a 422:

{"error":{"message":"no stored provider key can serve this request","type":"invalid_request_error","param":null,"code":"no_provider_key"},"request_id":"req_0000c5d0"}

Fix: store a key for a provider that serves the model, then send the call again. GET /v1/models lists the model IDs your stored keys can reach. With no stored keys the list is empty.

Other errors

StatusMessageCauseFix
401missing api key or invalid api keyThe key was not sent, or is wrong.Step 1.
400provider credential verification failedThe provider rejected the key you tried to store.Check the provider key. Nothing was saved.
422no stored provider key can serve this requestNo stored key reaches a provider that serves the model.Step 2.
404unknown modelThe model ID is not one Meadow lists.Use an ID from GET /v1/models, or pin the provider: google/<model>.
422no usable sandbox provider key stored for allowed providersNo daytona or modal key is stored.Step 4.
403key does not have sandboxes scopeThe key lacks the scope for the route.Step 5.
409sandbox is not runningThe sandbox ended, failed, or is still being created.Read its status. Create a new one.

Errors explains every error type and when a retry is safe.

Next

Operations used on this page: listProjects, putProviderKey, createChatCompletion, createSandbox, execInSandbox, deleteSandbox, createKey, listSandboxes.