> ## Documentation Index
> Fetch the complete documentation index at: https://to11.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> Install the to11 TypeScript SDK, render a prompt, and send it with your own provider client.

The `@to11ai/sdk` package gives TypeScript and JavaScript applications typed access to to11. You use it to render managed prompts at runtime, shaped for the provider client you already use, and to manage prompts, versions, skills, and project environments from code.

The SDK talks to the to11 API (`https://api.to11.ai`). It never sends the model request itself — there is no `.chat()`. Your own provider client (OpenAI, Anthropic, or any other) sends the rendered prompt to the provider, with your own provider key.

The package is published under the MPL-2.0 license and ships ESM, CommonJS, and TypeScript source in one package.

## Runtime requirements

* **Runtimes:** Node (both ESM and CommonJS), Bun, Deno, and edge runtimes, on a server, in a CLI, or in a backend job. No minimum Node version is declared.
* **Not in a browser:** a to11 API key must never ship in client code, so the SDK throws if you pass `apiKey` in a browser context.
* **Credentials:** a to11 API key and a project id. The SDK reads `TO11_API_KEY` and `TO11_PROJECT_ID` from the environment, and `TO11_API_URL` for the API address, which defaults to `https://api.to11.ai`.

## Installation

```bash npm theme={null}
npm install @to11ai/sdk
```

```bash pnpm theme={null}
pnpm add @to11ai/sdk
```

```bash bun theme={null}
bun add @to11ai/sdk
```

```bash yarn theme={null}
yarn add @to11ai/sdk
```

Install your provider client, such as `openai` or `@anthropic-ai/sdk`, separately; the SDK does not depend on it.

## The happy path

Create a client, render a prompt shaped for OpenAI, and send it with your OpenAI client:

```ts theme={null}
import { createClient } from "@to11ai/sdk";
import OpenAI from "openai";

// Reads TO11_API_KEY and TO11_PROJECT_ID from the environment.
const to11 = createClient({ format: "openai" });
const openai = new OpenAI(); // reads OPENAI_API_KEY

const prompt = await to11.prompts.render("welcome-message", {
  variables: { name: "Ada" },
});

const res = await openai.chat.completions.create({
  ...prompt.config,
  messages: prompt.messages,
});
```

`prompt.config` carries the model settings from the prompt version's **Config** pane, `prompt.messages` the rendered messages, and `prompt.metadata` which prompt version produced them, for your own logging.

## Where to next

> [card] [Configuration](https://to11.ai/docs/reference/typescript-sdk/configuration.md)
>
> Client options, credential resolution, and what the client exposes.

> [card] [Rendering prompts](https://to11.ai/docs/reference/typescript-sdk/rendering-prompts.md)
>
> Formats, the rendered result shape, and the converters.

> [card] [Prompt management](https://to11.ai/docs/reference/typescript-sdk/prompts.md)
>
> Prompt lifecycle, versions, labels, skills, and project environments.

> [card] [Errors](https://to11.ai/docs/reference/typescript-sdk/errors.md)
>
> The typed error classes the SDK throws, and how to catch them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.