Genkit OpenAI Plugin
OpenAI-compatible model provider for Genkit (OpenAI, Azure OpenAI, and other compatible endpoints).
Building with a coding agent? Install the Genkit Python skill first.
npx skills add genkit-ai/skills --skill developing-genkit-pythonIt teaches your agent the current Genkit Python APIs and common gotchas. Source, manual install and skills for other languages: genkit-ai/skills.
Installation
uv add genkit-openai
Usage
from genkit import Genkit
from genkit_openai import OpenAI
ai = Genkit(plugins=[OpenAI()])
res = await ai.generate(
model=OpenAI.gpt('gpt-5.2'),
prompt='Suggest 2 catchy names for an AI newsletter.',
)
print(res.text)
Set OPENAI_API_KEY in the environment, or pass api_key= to OpenAI().
base_url= points the plugin at another OpenAI-compatible server. Pass the URL
up to and including /v1; the SDK appends /chat/completions. Any other
AsyncOpenAI setting goes in client_options:
OpenAI(
api_key=key,
base_url='https://openrouter.ai/api/v1',
client_options={'organization': 'org-123', 'timeout': 30, 'max_retries': 5},
)
Config
config takes the settings OpenAIConfig declares. Any other key raises
before the request is sent, so a typo fails by name:
res = await ai.generate(
model='openai/gpt-4o',
prompt='Write a haiku about the sea.',
config={
'temperature': 0.2,
'max_output_tokens': 200, # caps reply length
'extra': {'reasoning': {'effort': 'low'}}, # fields OpenAIConfig doesn't declare
},
)
max_output_tokens(maxOutputTokensin the Dev UI) caps reply length. It goes out asmax_tokens, or asmax_completion_tokenson reasoning models.stop_sequencesgoes out asstop. OpenAI's own names (max_tokens,max_completion_tokens,stop) are not declared onOpenAIConfig, so passing them at the top level raisesINVALID_ARGUMENT.extragoes out as top-level request body fields. A key inextrareplaces a setting of the same name (includingmax_tokensormax_completion_tokensfor OpenAI-compatible servers). An API key inconfigorextraraisesINVALID_ARGUMENT; it belongs incontext.secrets.
Per-request API key
To bill a call to someone else's OpenAI account, pass their key in
context.secrets. It's used for that call only, on chat, image,
text-to-speech, and transcription models:
res = await ai.generate(
model='openai/gpt-4o',
prompt='hi',
context={'secrets': {'api_key': tenant_key}},
)
apiKeyworks as well asapi_key. Other entries incontext.secretsare left alone, so a call whose secrets hold no key runs on the plugin's key. A key that is blank or not a string raisesINVALID_ARGUMENT.- The tenant call sends only the tenant's key. The plugin's
organization,project,OPENAI_ORG_IDandOPENAI_PROJECT_IDare left off;base_url, timeouts and otherdefault_headerscarry over. A plugin whosedefault_headerspinAuthorizationrefuses a tenant key withFAILED_PRECONDITION. - The plugin doesn't need a key of its own for chat, image, text-to-speech,
and transcription models:
OpenAI()with noOPENAI_API_KEYserves every call that brings a key incontext.secrets, and a call without one fails withFAILED_PRECONDITION. - Embedders run on the plugin's key only, since
ai.embed()takes nocontext. On a plugin without a key they fail withFAILED_PRECONDITION.
Metadata
Release files for genkit-openai 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| genkit_openai-0.13.0.tar.gz | 79.1 kB | With provenance | Details for genkit_openai-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genkit_openai-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for genkit_openai-0.13.0-py3-none-any.whl |
Total release size: 126.7 kB
Release files / genkit_openai-0.13.0.tar.gz
| Download URL | genkit_openai-0.13.0.tar.gz |
|---|---|
| Size | 79.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e6d84679e9cdb8a2c26aea7c95863991a92a467ba448d1a8b0b5d32e7444d5e
|
|
BLAKE2b-256 checksum How to use checksums |
264d525ec4a032be45990c511f7ea52048271da6937c9fdd69c18585646f37fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / genkit_openai-0.13.0-py3-none-any.whl
| Download URL | genkit_openai-0.13.0-py3-none-any.whl |
|---|---|
| Size | 47.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db1849850cb462f1f29e120f87b3ee14770f83284a25bb33086d3e7ae4a8932b
|
|
BLAKE2b-256 checksum How to use checksums |
4b44a4e1678f691ac703f6b43809c6a9df1f131eeb2519d12a3876f566b2ac54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for genkit-openai 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for genkit_openai-0.13.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.