aeat.adapters.outbound.llm._providers.openai module

OpenAI provider adapter for the LLM outbound subpackage.

Speaks the OpenAI /v1/chat/completions HTTP API and adapts its response into the ProviderCompletion contract.

class OpenAIAdapter(api_key, timeout_s)[source]

Bases: _ProviderAdapter

Provider adapter that invokes the OpenAI Chat Completions API.

A non-empty api_key is mandatory; the adapter refuses to construct without one because the underlying API rejects unauthenticated calls.

Parameters:
  • api_key (str)

  • timeout_s (int)

provider: LLMProvider
async complete(request)[source]

Execute a Chat Completions request against the OpenAI API.

Parameters:

request (ProviderRequest) – Normalized provider request.

Return type:

ProviderCompletion

Returns:

A ProviderCompletion with the first choice’s trimmed text and reported token counts.

Raises:

LLMProviderError – When the API returns a 4xx or 5xx HTTP error status.