---
title: OpenAI
description: Completions, streams, and tool calls.
---

# OpenAI

Use the official `openai` package. Agenko does not wrap your client in an Agenko-specific class.

```python
import openai
import agenko

agenko.init()

client = openai.OpenAI()

@agenko.check
def answer(question: str) -> str:
    res = client.chat.completions.create(
        model="gpt-4.1-mini",
        messages=[{"role": "user", "content": question}],
    )
    return res.choices[0].message.content or ""
```

```typescript
import OpenAI from "openai";
import agenko from "@agenko/sdk";

agenko.init();
const client = new OpenAI();

const answer = agenko.check(async (question: string) => {
  const res = await client.chat.completions.create({
    model: "gpt-4.1-mini",
    messages: [{ role: "user", content: question }],
  });
  return res.choices[0].message.content ?? "";
});
```

## What you get

Completions, streamed tokens, and tool calls become OTEL spans (OpenInference OpenAI instrumentor). `@check` maps `tool.name` / `gen_ai.tool.*` into claimed vs actual.

Optional: `import agenko.openai` for the explicit drop-in. Auto-detect is enough for most apps.

## Agent instructions

This page: https://docs.agenko.app/openai-sdk.md

Fetch `/llms.txt` for the full index. Search: `GET /api/search-docs?query=...`
