OpenAI Compatibility#
- saia_python.create_openai_client(*, api_key: str | None = None, base_url: str | None = None, key_file: str | None = None, async_client: bool = False)[source]#
Create an OpenAI client configured for the SAIA platform.
Reuses the same credential and base URL resolution as
SAIAClient: environment variables,.env,.saia_api, andconfig.tomlare checked automatically when parameters are omitted.- Parameters:
api_key – Explicit API key. If omitted, resolved via
load_api_key().base_url – Explicit base URL. If omitted, resolved via
resolve_base_url().key_file – Path to a
.saia_apior.envfile. Ignored whenapi_keyis provided.async_client – If
True, return anopenai.AsyncOpenAIinstance instead ofopenai.OpenAI.
- Returns:
An
openai.OpenAIoropenai.AsyncOpenAIinstance.
Example:
from saia_python import create_openai_client client = create_openai_client() response = client.chat.completions.create( model="llama-3.3-70b-instruct", messages=[{"role": "user", "content": "Hello!"}], ) # Embeddings embedding = client.embeddings.create( model="e5-mistral-7b-instruct", input="Text to embed", )