Getting Started

Run your first Agent

Run one TypeScript file that prints a streamed answer and the server-minted Session ID. The program creates an Agent with no optional resources, then starts its first Turn.

Before you begin

Complete Set up Blazing Agents and make the configured client available to this file. You do not need to configure a Provider, Skill, Sandbox, MCP connection, Memory, or Task.

Create an Agent

name is the only required creation field. With providerId omitted, the Agent uses the platform key and the default model.

Run the first Turn

Save this complete file as quickstart.ts:

quickstart.ts
import { type UIMessage } from "@blazing-agents/sdk";
import { client } from "./client.ts";

const agent = await client.agents.create({
  name: `Quickstart Agent ${crypto.randomUUID()}`,
});

const message = {
  id: crypto.randomUUID(),
  role: "user",
  parts: [{ type: "text", text: "Reply with: First Turn complete." }],
} satisfies UIMessage;

const result = await client.chat({ agentId: agent.id, message });
const sessionId = await result.sessionId;

console.log(`Agent: ${agent.id}`);
console.log(`Session: ${sessionId}`);

for await (const chunk of result.toUIMessageStream()) {
  if (chunk.type === "text-delta") {
    process.stdout.write(chunk.delta);
  }
}
process.stdout.write("\n");

client.chat() accepts one valid user UIMessage. Because the call omits sessionId, it starts a new Session and returns a decoded stream that the loop consumes once.

Verify the result

Run the file with your TypeScript runner. Standard output shows an ag_... Agent ID, an ss_... Session ID, and the streamed answer, including First Turn complete. when the model follows the instruction.

Understand what was created

Omitting sessionId selects the create path. Blazing Agents mints the ss_... ID and returns it in the response Location header; the SDK exposes it as result.sessionId before the body finishes streaming.

The ID is provisional at that point. The Session record and successful transcript are persisted only when the first Turn succeeds. See Sessions and Turns for the full lifecycle.

Production notes

  • Store the Session ID only after the first Turn succeeds.
  • Pass the caller's AbortSignal as signal when cancellation should stop the Turn.
  • Keep the API key on your backend and out of browser or mobile code.

Reference

On this page