Agent Platform

Migrate from direct model provider API usage

Replace your Anthropic, OpenAI, or OpenRouter calls with Agent Platform. In our (limited) tests we found that this adds around 2 to 3 seconds of latency to all responses.

PreviousWith Agent Platform
Store a provider API key in your backendStore AP_API_KEY in your backend
Create one chat or responses requestCreate or reuse a session, then create a run
Pass prior messages each timeReuse the same session_id
Stream provider tokensStream run_event records
Call tools from your own integration layerUse gateway-backed actions inside runs or action_invocations
Build your own request logInspect runs and events in /dashboard/runs

Why Agent Platform

  • One key instead of separate provider and integration credentials
  • Workspace scoping and audit through the platform gateway
  • Durable event timelines for debugging and replay
  • Same execution model across the CLI, dashboard, and API

Agent Platform doesn't replace every provider call in your system. If a backend job only needs one known action, call action_invocations directly and skip sessions entirely.

Minimal replacement pattern

  1. Replace your provider client with a thin Agent Platform client.
  2. Create a session when a user starts a new conversation or task.
  3. Create runs inside that session for each prompt.
  4. Use wait: true for request/response handlers and stream: true for interactive UIs.
  5. Use action_invocations for deterministic calls that don't need model reasoning.

Example

Before (Anthropic)

await anthropic.messages.create({
  model: "claude-sonnet-4-5",
  messages: [{ role: "user", content: "Summarize open incidents." }],
});

After (Agent Platform)

const session = await apFetch("/sessions", {
  method: "POST",
  body: JSON.stringify({ title: "Incident review" }),
});

const run = await apFetch(`/sessions/${session.id}/runs`, {
  method: "POST",
  body: JSON.stringify({
    input: [
      {
        role: "user",
        content: [{ type: "input_text", text: "Summarize open incidents." }],
      },
    ],
    wait: true,
  }),
});

When not to use a run

Skip sessions and runs when you already know the exact action to call and only need the gateway result. Call POST /v1/action_invocations directly instead.

Next

On this page