Skip to main content
Use this page when your application already calls the OpenAI SDK. The wrappers keep the OpenAI client shape and add Averta checkpoints around supported calls.

Install

Python support is source-install only until averta-openai is published to PyPI. Run the Python install command from the SDK repository.
The OpenAI wrapper reads AVERTA_API_KEY from the environment. Pass avertaApiKey or averta_api_key only when this client should use a different Averta key.

Wrap the Client

Do not wrap the same OpenAI client twice. Create a fresh OpenAI client for each distinct Averta configuration.

Send a Tool-capable Request

At this point Averta has run the request checkpoint. If policy returns restrict_tools, the wrapper forwards only the allowed tools to OpenAI.

Continue the Tool Loop

OpenAI function calls include a call_id. Use that value when you send the result back.
When the continuation request is sent, Averta evaluates the tool result before OpenAI sees it.

Confirm Decisions

With an allowing policy and a tool call, Events should show a sequence like:
The exact sequence depends on whether the model calls a tool. A request with no tool call can skip tool_call and tool_result. The SDK generates requestId and traceId automatically; pass requestContext only when you need your own conversationId, requestId, or traceId.

Runnable Example

The SDK repository includes runnable OpenAI examples:
Fill OPENAI_API_KEY and AVERTA_API_KEY in examples/.env before running an example.

Chat Completions

The same wrapped client also guards supported Chat Completions calls.

Python Support

Python V1 wraps sync OpenAI clients and guards responses.create(...), responses.create(stream=True, ...), responses.stream(...), chat.completions.create(...), and chat.completions.create(stream=True, ...).

Next Steps

Responses API

See the guarded Responses lifecycle.

Tools

Understand tool exposure and tool-call checks.

Output checks

Evaluate final answers before returning them.

Events

Investigate decisions in the dashboard.