Agent Platform

Examples

You're probably better off feeding this page to Claude Code, OpenCode, or your favorite harness and letting it figure out the integration for you. The full API spec is at /v1/openapi.json.

TypeScript

const AP_BASE_URL = "https://api.agentplatform.cloud/v1";
const AP_API_KEY = process.env.AP_API_KEY!;

async function apFetch<T>(path: string, init: RequestInit = {}): Promise<T> {
  const response = await fetch(`${AP_BASE_URL}${path}`, {
    ...init,
    headers: {
      Authorization: `Bearer ${AP_API_KEY}`,
      "Content-Type": "application/json",
      ...(init.headers ?? {}),
    },
  });

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error ?? "Agent Platform request failed");
  }

  return response.json() as Promise<T>;
}

const session = await apFetch<{ id: string }>("/sessions", {
  method: "POST",
  body: JSON.stringify({ title: "Backlog triage" }),
});

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

TypeScript: streaming via Next.js

Proxy the stream through your backend. Never expose AP_API_KEY to the browser.

export async function POST(request: Request) {
  const { sessionId, prompt } = await request.json();

  const upstream = await fetch(
    `https://api.agentplatform.cloud/v1/sessions/${sessionId}/runs`,
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.AP_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        input: [
          {
            role: "user",
            content: [{ type: "input_text", text: prompt }],
          },
        ],
        stream: true,
      }),
    },
  );

  return new Response(upstream.body, {
    status: upstream.status,
    headers: {
      "Content-Type": "text/event-stream",
      "Cache-Control": "no-cache",
    },
  });
}

Python

import os
import requests

AP_BASE_URL = "https://api.agentplatform.cloud/v1"
AP_API_KEY = os.environ["AP_API_KEY"]


def ap_post(path: str, payload: dict):
    response = requests.post(
        f"{AP_BASE_URL}{path}",
        json=payload,
        headers={
            "Authorization": f"Bearer {AP_API_KEY}",
            "Content-Type": "application/json",
        },
        timeout=60,
    )
    response.raise_for_status()
    return response.json()


session = ap_post("/sessions", {"title": "Backlog triage"})
run = ap_post(
    f"/sessions/{session['id']}/runs",
    {
        "input": [
            {
                "role": "user",
                "content": [{"type": "input_text", "text": "Summarize open P1 bugs."}],
            }
        ],
        "wait": True,
    },
)
print(run["output"][0]["content"][0]["text"])

Direct action call

Skip sessions and runs when you already know the exact action you need.

curl https://api.agentplatform.cloud/v1/action_invocations \
  -H "Authorization: Bearer $AP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "linear.issues.list",
    "input": { "query": "priority:urgent" }
  }'

On this page