Deploy a model
Deployments, API keys and the OpenAI API for your apps.
A deployment serves a model for your apps. It belongs to the workspace, not to you, and runs on as many replicas as its traffic needs, down to none when nobody calls it.
Deploy a model
On a model's page, Deploy (or its Deployments tab): give it a name (it is the API's model), a size, and how many replicas. Or from your terminal:
workbox deploy tiny-shakespeare-12 --name shakespeare --min 0 --max 3| Setting | What it does |
|---|---|
| Size | The GPU each replica runs on: the model's size, unless you choose |
| Fewest replicas | 0 lets it scale to none when quiet. The next request then waits while a replica starts |
| Most replicas | The most it scales up to |
| Requests per replica | Open requests a replica takes before another starts |
| Idle minutes | With no requests for this long, it goes down to its fewest replicas |
| Browser origins | Web pages on these origins may call it. None by default: keys belong on servers |
Roll out another model (a newer job's, or a fine-tune) from its page's Deployments tab, with no downtime: its replicas start, requests move to them once one is ready, and the old ones finish what they're answering. Roll back to an earlier revision the same way. Pause stops its replicas; Delete ends it.
A project can roll out the model of every successful push by itself:
deploy:
name: shakespeare
replicas: { min: 0, max: 3 }Replicas count in the workspace's spending like boxes. At its monthly cap a deployment stops scaling up and new requests are refused with insufficient_quota; whoever made it is told.
Call it
Make a key in Settings, API keys (owners and admins). It is shown once. Then use any OpenAI SDK, changing only the base URL and the key:
from openai import OpenAI
client = OpenAI(base_url="https://<models address>/v1", api_key="wbx_live_...")
stream = client.chat.completions.create(
model="shakespeare",
messages=[{"role": "user", "content": "Write a sonnet."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")Every deployment is called at the same base URL, like https://workbox.fyi/v1, with its name as model. The Deployments tab shows the base URL and ready-to-copy curl, Python and JavaScript.
| Endpoint | |
|---|---|
GET /v1/models | The deployments your key may call |
POST /v1/chat/completions | Chat, streamed or not |
POST /v1/completions | Text completion |
POST /v1/embeddings | Where the engine has it |
Keys and limits
A key may call every deployment or the ones you choose, and may also manage deployments (the API). Each can have its own limit of requests and tokens a minute, and an expiry. Revoking one takes effect within seconds.
Errors
Errors are in OpenAI's shape, {"error": {"message", "type", "code"}}:
| Status | Code | Means |
|---|---|---|
| 401 | invalid_api_key | The key is wrong, revoked or expired |
| 403 | model_not_allowed | The key may not call that deployment, or a browser's origin isn't listed |
| 404 | model_not_found | No deployment by that name in the key's workspace |
| 413 | request_too_large | The body is over 10 MB |
| 429 | rate_limit_exceeded | The key's limit for this minute is used; Retry-After says when to try again |
| 429 | insufficient_quota | The workspace has reached its spending cap |
| 503 | model_starting | No replica was ready in time; try again shortly |
Next: The management API