OpenAIInference#
- class rapidtools.models.OpenAIInference(api_key: str | Path | None = None, model_id: str | None = None, max_workers: int = 10, max_retries: int = 3, system_instruction: str | None = None, temperature: float = 0.4, max_tokens: int = 2048, timeout: float = 60.0, base_url: str | None = None)[source]#
Bases:
BaseOpenAICompatibleInferenceOpenAI Chat Completions client for image + text prompts.
The key is read from
api_key(string or key-file path) or theOPENAI_API_KEYenvironment variable. Reasoning models (GPT-5.x, GPT-6, o-series) do not accepttemperature; it is omitted automatically.Example
>>> from rapidtools.models import OpenAIInference >>> OpenAIInference.list_known_models()[:2] ['gpt-6-astra', 'gpt-6-sol'] >>> model = OpenAIInference(api_key='sk-...') >>> for asset_id, status, out in model.run_batch( ... [('b1', ['b1.jpg']), ('b2', ['b2.jpg'])], 'Rate the damage 0-5.' ... ): ... print(asset_id, status, out.text if status == 'ok' else out)
Methods
list_available_modelsList the model IDs accessible with
api_key.list_known_modelsReturn the curated catalogue of model IDs for this provider.
run_batchRun
run_inference()over many assets with a thread pool.run_inferenceSend images and a prompt to
/chat/completions.