Skip to content
OpenPond
Join community
Ponder SDK/Serving

Serving

Call a deployed Model from TypeScript, Python, a React backend, or an MCP tool.

Use the exact callable Model ID from the active deployment. These examples use the ticket router's saved system prompt from Model setup, so each call sends the ticket text. Save the attempt ID alongside the suggestion. When the ticket is resolved, send the verified queue with the stable event ID from your application.

typescript
import { createPonder } from "ponder-sdk"; const pond = createPonder({ apiKey }); const router = pond.model(callableModelId); const answer = await router.generate({ prompt: ticket.body }); await saveSuggestion(ticket.id, answer.text, answer.attemptId); // In your resolution handler, using the saved attempt ID. await pond.feedback({ attemptId, eventId: resolution.id, expectedOutput: { queue: resolution.queue }, });

Eligible requests collect one observation in the linked Dataset. A finished stream has the same attempt handle as a non-streamed response. The serving request ID lets you recover a retained result. Use the attempt ID to attach or inspect a correction. Feedback can arrive while Dataset collection is pending and retains the original prediction. Serving and collection

React and the Vercel AI SDK

From React, call your authenticated backend route with fetch("/api/tickets/route", …). Keep the Ponder client and API key on that server. The route can call the Model directly or use the optional Vercel AI SDK integration. Install ai@^7.0.165 and @ai-sdk/openai-compatible@^3.0.87 on the server.

typescript
import { generateText } from "ai"; import { toAIModel } from "ponder-sdk/ai-sdk"; const result = await generateText({ model: toAIModel(router), prompt: "I was charged twice.", maxRetries: 0, }); const attemptId = result.providerMetadata?.openpond?.attemptId;

The stream's provider metadata carries the attempt ID after completion. AI SDK installation and streaming

HTTP and MCP

typescript
const response = await fetch("https://api.openpond.ai/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: callableModelId, messages: [{ role: "user", content: ticket.body }], }), }); if (!response.ok) throw new Error(`Serving returned HTTP ${response.status}`); const completion = await response.json(); const attemptId = completion.openpond?.attemptId;

Send feedback to POST /v1/model-projects/configuration/attempt-feedback with the same workspace in X-OpenPond-Team-Id and a JSON body containing attemptId, eventId and expectedOutput.

An application-owned MCP tool can call the same server-side Model.

typescript
async function routeTicket({ text }: { text: string }) { const answer = await router.generate({ prompt: text }); return { content: [{ type: "text" as const, text: answer.text }], structuredContent: { queue: answer.text.trim(), attemptId: answer.attemptId ?? null, }, }; }

Capture a run from your application

Use the portable Model project ID when recording an attempt from your own provider or agent. The task ID groups runs on one ticket and the run ID identifies a single attempt.

typescript
const attempt = await pond.model("ticket-router").recordAttempt({ id: run.id, task: { id: ticket.id, input: { text: ticket.body } }, output: { queue: run.suggestedQueue }, trace: [ { kind: "tool", tool: "lookupTicket", input: { id: ticket.id }, output: { status: "open" }, }, ], });

For a step the hosted Model already collected, use { kind: "hosted", attemptId } in the trace. Use pond.inspectAttempt(attempt.attemptId, { eventId }) to read the original observation and the later feedback receipt.

View as Markdown