Skip to main content
Use TypeScript today with a thin typed wrapper around the REST API. This gives you strong IDE support immediately while preserving compatibility with the future public SDK.

Typed create-agent example

type CreateAgentResponse = {
  agent_id: string;
};

const response = await fetch("https://api.threetone.in/v1/convai/agents/create", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "YOUR_API_KEY",
  },
  body: JSON.stringify({
    name: "Customer Support Agent",
    system_prompt: "You are a helpful customer support representative.",
  }),
});

if (!response.ok) {
  throw new Error(`Create agent failed: ${response.status}`);
}

const agent = (await response.json()) as CreateAgentResponse;
console.log(agent.agent_id);
Canonical source file: /examples/typescript/create-agent.ts
  • Define response types at the boundary of your ThreeTone client
  • Keep request builders small and composable
  • Use a central auth helper for the x-api-key header