Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

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-python

It 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()])


async def main() -> None:
    res = await ai.generate(
        model=OpenAI.gpt('gpt-5.2'),
        prompt='Suggest 2 catchy names for an AI newsletter.',
    )
    print(res.text)
    # => 1. The Neural Brief
    #    2. Prompt & Circumstance


if __name__ == '__main__':
    ai.run_main(main())

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('gpt-4o'),
    prompt='Write a haiku about the sea.',
    config={
        'temperature': 0.2,
        'max_output_tokens': 200,  # caps reply length
        'extra': {'user': 'diner-42'},  # a field OpenAIConfig doesn't declare
    },
)
  • max_output_tokens (maxOutputTokens in the Dev UI) caps reply length. It goes out as max_tokens, or as max_completion_tokens on reasoning models and whenever reasoning_effort is set. stop_sequences goes out as stop. OpenAI's own names (max_tokens, max_completion_tokens, stop) are not declared on OpenAIConfig, so passing them at the top level raises INVALID_ARGUMENT.
  • extra goes out as top-level request body fields. A key in extra replaces a setting of the same name (including max_tokens or max_completion_tokens for OpenAI-compatible servers). An API key in config or extra raises INVALID_ARGUMENT; it belongs in context.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 every model and embedder the plugin serves:

res = await ai.generate(
    model=OpenAI.gpt('gpt-4o'),
    prompt='hi',
    context={'secrets': {'api_key': tenant_key}},
)
  • apiKey works as well as api_key. Other entries in context.secrets are 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 raises INVALID_ARGUMENT.
  • The tenant call sends only the tenant's key. The plugin's organization, project, OPENAI_ORG_ID and OPENAI_PROJECT_ID are left off; base_url, timeouts and other default_headers carry over. A plugin whose default_headers pin Authorization refuses a tenant key with FAILED_PRECONDITION.
  • The plugin doesn't need a key of its own: OpenAI() with no OPENAI_API_KEY serves every generate() or embed() call that brings a key in context.secrets, and a call without one fails with FAILED_PRECONDITION.
  • Embedders read the same key: ai.embed(..., context={'secrets': {'api_key': tenant_key}}). A call without one runs on the plugin's key.

Metadata

Release files for genkit-openai 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for genkit-openai 0.14.0
File Size Uploaded Provenance Actions
genkit_openai-0.14.0.tar.gz 82.9 kB With provenance Details for genkit_openai-0.14.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for genkit-openai 0.14.0
File Interpreter ABI Platform Actions
genkit_openai-0.14.0-py3-none-any.whl Python 3 none any Details for genkit_openai-0.14.0-py3-none-any.whl

Total release size: 132.2 kB

Release files / genkit_openai-0.14.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL genkit_openai-0.14.0.tar.gz
Size 82.9 kB
Tags Source
SHA-256 checksum
How to use checksums
61858ead8780ec1e3e964f941de4edf390a98933a5ef5ce26f48ee302ea3fe87
BLAKE2b-256 checksum
How to use checksums
93905d6839be137b1b62f9aa2f7eca2c14a8c41c7d7cb7ac5bb7cd0bfc89f3d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 19, 2026.

Transparency log

Release files / genkit_openai-0.14.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL genkit_openai-0.14.0-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
361c6578cdc86d5d525ad08c2a5e56d857ac6d8280d5ca057dafcb0549cceb11
BLAKE2b-256 checksum
How to use checksums
1e3cf3282b38e5a292ef3456bb033c4e36fbfdcc5dca40209d0bcf036b1bc608
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 19, 2026.

Transparency log

Security for genkit-openai 0.14.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.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for genkit_openai-0.14.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 19, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page