Playcode AI Gateway
Give your product its own AI agent.
It does real work in your app: reads the PDF a customer uploads, finds the order, books the slot and sends the email. It runs on the engine behind Playcode AI, and Playcode AI can build it for you.
For Cloud apps on a Pro or Max plan. No AI account to open: each request uses your workspace's credits.

Playcode inside your Playcode app.
AI that builds your product.
Playcode AI Gateway
AI your product puts to work.
One engine runs both. The part of Playcode AI that calls the model, runs the tools, keeps the conversation and counts the cost is in @playcode/sdk. Our own agent runs on it every turn, so every improvement is tested on real work first, and your agents get it with the next SDK update.
Agents that do the work, not just the talking.
An agent uses your app's functions as its tools, so it can do what your app can do. Six jobs from the docs, each with its code:
- Read a PDF, act on itA customer uploads an invoice or a form. The agent reads it into checked fields and emails your team the result.
- A chat for your customersEach customer gets their own conversations. The agent checks orders and books slots through your app.
- Answers from your own dataIt looks things up in your articles and records, and names the ones it used.
- Approval before it actsA refund over your limit waits for a person on your team.
- Work that survives a restartA long run or a weekly report picks up where it stopped.
- A memory of each userIt remembers what each customer told it before.
Describe the agent. Playcode AI builds it in.
“Add a chat where customers can check their order and book a delivery slot.”
- It switches on AI for the app, if it is off.
- It writes the agent, its tools and the chat page.
- It tests the agent with one real request, which uses your credits.

Or write it in a few lines.
An agent is a model, your instructions and your functions as tools. Pick any model from playcode.ai.models(): change the id, keep the code. Give a run a budget, and it stops there.
import { Playcode, tool } from '@playcode/sdk'
import { z } from 'zod'
const playcode = new Playcode()
const [model] = await playcode.ai.models()
const desk = playcode.ai.agent({
model: model.id,
system: 'You help customers with their orders.',
tools: {
findOrder: tool({
description: 'Finds an order by its number.',
input: z.object({ number: z.string() }),
execute: ({ number }) => db.orders.find(number),
}),
},
})
const { text } = await desk.run('Where is my order?')Need a model maker's own SDK, such as Anthropic's? playcode.ai.endpoint() gives its base URL and your app's key. A new Cloud app has the SDK installed, an agent store in its database and a chat page that talks to an example agent.
Agents loop, forget and overspend. Ours were taught not to.
Four safeguards are on from the start, with no code of yours, and two more take one line each:
- Brakes
- A run that repeats itself is told to change course, then stopped.
- Long conversations
- Old tool results are cleared, then summed up, as a conversation grows.
- Tool limits
- A slow tool times out, and a huge result is cut.
- Safe retries
- A call is retried only when Playcode shows nothing was charged.
- Budgets
- Give a run a budget, and it stops there.
- Approvals
- Mark a tool, and it waits for a person before it acts.
Your key stays on your server: the browser calls your app's own endpoint, and only your server calls Playcode AI Gateway.
Pay per request, at the model's own rate.
It is the same rate Playcode AI pays for that model in the chat. Every result says what it cost, and every call can carry your customer's id, so you see what each user costs.
Set a monthly AI budget for the app and a daily limit per user. Settings, Usage shows the AI Gateway row with its requests and tokens.
Questions about Playcode AI Gateway

Is it the same agent as Playcode AI?
The same engine. Playcode AI and your app's agents both run on it; your agent does the job you give it, with your app's functions as its tools.
Do I need an Anthropic or OpenAI account?
No. Your app calls the models with its Playcode key, and each request uses your workspace's credits. That key works only through Playcode AI Gateway.
Which models can my app use?
Claude models and models from other makers. The list and the prices change over time, so your app reads them from playcode.ai.models(), and Playcode AI reads them for you.
Can I keep using the Anthropic SDK?
Yes. playcode.ai.endpoint() gives the base URL and key for a model maker's own SDK, for a feature only that SDK has.
What can an agent not do yet?
It reads text, images and PDFs, not audio or video. It cannot run a model maker's own tools, such as web search: a tool of yours can call a search API instead. Image generation from your app's key is not available yet.
What happens when my credits run out?
Requests pause until you add credits, and a run ends with a clear reason. If the credits run out while a model is answering, the answer stops there, and the text that arrived is delivered and billed.
Can a static site use AI Gateway?
No. AI needs a Cloud app: a static site has no server to keep the key.
Give your product an agent.
