Quickstart

Use Python 3.10–3.14 and an OpenAI API project with access to gpt-6.2-astra.

Install the adapter

In a Bash terminal, create a virtual environment and install the version used by this guide.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install llm-api-adapter==0.11.0

Set up the API key

Set OPENAI_API_KEY in the environment of the terminal where you run Python. Use a key from your OpenAI API project.

Send a chat request

Save this example as quickstart.py and run python quickstart.py. It prints a short greeting.

import os

from llm_api_adapter.models.messages.chat_message import UserMessage
from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter

api_key = os.environ.get("OPENAI_API_KEY")
if not api_key:
    raise SystemExit("Set OPENAI_API_KEY before running this example.")

adapter = UniversalLLMAPIAdapter(
    organization="openai",
    model="gpt-6.2-astra",
    api_key=api_key,
)
response = adapter.chat(
    messages=[UserMessage("Reply with a short greeting.")],
    reasoning_level="low",
    max_tokens=512,
    timeout_s=30,
)
if not response.content or not response.content.strip():
    raise SystemExit("The model completed without a text response.")
print(response.content)

See model limits and pricing