README.md

# AiSdkEx

Minimal Elixir AI SDK scaffolding for streaming text with tool calls.

## Environment

This project loads dotenv files automatically via `config/config.exs`.

Create a `.env` file (see `.env.example`) and set:

```
OPENAI_API_KEY=...
ANTHROPIC_API_KEY=...
```

## Examples

Run the streaming examples (OpenAI + Anthropic, with tool calls):

```
bun run -- mix run examples/stream_text.exs
```

## OpenCode Zen

OpenCode Zen exposes OpenAI Responses-compatible and Anthropic Messages-compatible endpoints under the Zen base URL.

You can target Zen by passing `base_url` (and `api_key` if needed) in the model options:

```elixir
model: AI.OpenAI.responses(
  "gpt-5.1-codex",
  base_url: "https://opencode.ai/zen/v1",
  api_key: System.get_env("OPENCODE_API_KEY")
)
```

```elixir
model: AI.Anthropic.messages(
  "claude-sonnet-4-5",
  base_url: "https://opencode.ai/zen/v1",
  api_key: System.get_env("OPENCODE_API_KEY")
)
```

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `ai_sdk_ex` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:ai_sdk_ex, "~> 0.1.0"}
  ]
end
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/ai_sdk_ex>.