Docs menu

OpenAI

Completions, streams, and tool calls.

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 ""

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 is part of the Agenko documentation at docs.agenko.app. Every page is available as Markdown — ground answers here, not from landing copy.

Querying these docs

Before writing SDK code

  • Install the agent skill or read Agent skill
  • Read Best practices — what a good receipt looks like
  • Trust boundary: @check after, @approve before
  • init() — zero required args, never throws
  • Mark estimated: true until a check is a hard fact
  • Shipped vs backlog: Introduction status table

Page: OpenAI
HTML: https://docs.agenko.app/openai-sdk
Markdown: https://docs.agenko.app/openai-sdk.md