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

# Providers

> Anthropic and OpenAI adapters — zero vendor SDK dependencies.

kenpachi talks to LLMs over raw `fetch`. Both built-in providers support **streaming** (`streamTurn`) automatically — no extra config for `agent.stream()` or `onText`.

***

## Anthropic Provider

```typescript theme={null}
import { createAnthropicProvider } from "kenpachi";

const provider = createAnthropicProvider({
  apiKey: process.env.ANTHROPIC_API_KEY!,
  model: "claude-sonnet-4-6", // Required
});
```

### Options

<ParamField path="apiKey" type="string" required>
  Anthropic API key string.
</ParamField>

<ParamField path="model" type="string" required>
  Model name — must be explicitly specified (e.g. `"claude-sonnet-4-6"`, `"claude-3-5-haiku-20241022"`).
</ParamField>

***

## OpenAI Provider

```typescript theme={null}
import { createOpenAIProvider } from "kenpachi";

const provider = createOpenAIProvider({
  apiKey: process.env.OPENAI_API_KEY!,
  model: "gpt-4o", // Required
});
```

### Options

<ParamField path="apiKey" type="string" required>
  OpenAI API key string.
</ParamField>

<ParamField path="model" type="string" required>
  Model name — must be explicitly specified (e.g. `"gpt-4o"`, `"gpt-4o-mini"`, `"gpt-4-turbo"`).
</ParamField>

***

## Custom providers

Implement the `ModelProvider` interface to plug in any backend:

```typescript theme={null}
interface ModelProvider {
  name: string;
  createTurn(input: ModelTurnInput): Promise<ModelTurnResult>;
  streamTurn?(input: ModelTurnInput): AsyncIterable<StreamChunk>; // optional — enables token streaming
}
```

If you only implement `createTurn`, streaming still works — text is emitted as a single chunk.

***

## Tool Serialization Across Providers

`kenpachi` automatically converts Zod tool schemas into standard JSON Schemas (`serializeZodSchema`) and maps them to provider-specific function declaration shapes:

### Anthropic Provider

Maps tools to Anthropic's expected `input_schema` shape:

```typescript theme={null}
{
  name: tool.name,
  description: tool.description,
  input_schema: {
    type: "object",
    properties: serializedProperties,
    required: serializedRequired
  }
}
```

### OpenAI Provider

Maps tools to OpenAI's function declaration shape:

```typescript theme={null}
{
  type: "function",
  function: {
    name: tool.name,
    description: tool.description,
    parameters: {
      type: "object",
      properties: serializedProperties,
      required: serializedRequired
    }
  }
}
```
