Skip to main content
Obiguard has native integrations with OpenAI SDKs for Python, and its REST APIs.
Provider slug: openai

Using the Obiguard Gateway

To integrate the Obiguard gateway with OpenAI,
  • Set the baseURL to the Obiguard Gateway URL
  • Include Obiguard-specific headers such as provider, obiguardApiKey, and others.
Here’s how to apply it to a chat completion request:
Install the Obiguard SDK with pip
This request will be logged automatically by Obiguard and can be viewed in your logs dashboard. Obiguard tracks the tokens used, execution time, and cost for each request. You can also examine detailed request and response data.
Obiguard supports OpenAI’s new “developer” role in chat completions. Starting with o1 models, the developer role replaces the previous system role.

Using the Responses API

OpenAI has introduced a new Responses API that merges the capabilities of Chat Completions and Assistants APIs. Obiguard provides full support for this API, allowing its use with both the Obiguard SDK and the OpenAI SDK.
The Responses API offers a more adaptable framework for creating agentic applications with integrated tools that run automatically.

Remote MCP Support in Responses API

Learn how Obiguard enables Remote MCP support for OpenAI’s Responses API.

Realtime API

Obiguard seamlessly integrates with OpenAI’s Realtime API, enabling features like logging, cost tracking, and guardrails.

Realtime API

Streaming Responses

Obiguard supports streaming responses through Server-Sent Events (SSE).

Streaming with the Responses API

You can also stream responses from the Responses API:

Vision Models Support

Obiguard’s multimodal Gateway provides full compatibility with OpenAI vision models. Refer to this guide for additional details:

Using Vision Models with the Responses API

The Responses API also enables processing images alongside text:

Function Calling

Function calls within your OpenAI or Obiguard SDK operations remain standard. These logs will appear in Obiguard, highlighting the utilized functions and their outputs. Additionally, you can define functions within your prompts and invoke the obiguard.prompts.completions.create method as above.

Function Calling with the Responses API

The Responses API also supports function calling with the same powerful capabilities:

Image Generation

Obiguard supports multiple modalities for OpenAI and you can make image generation requests through Obiguard’s AI Gateway the same way as making completion calls.

Audio - Transcription, Translation, and Text-to-Speech

Obiguard’s multimodal Gateway also supports the audio methods on OpenAI API. Check out the below guides for more info: Check out the below guides for more info:

Integrated Tools with Responses API

Web Search Tool

Web search delivers accurate and clearly-cited answers from the web, using the same tool as search in ChatGPT:
Options for search_context_size:
  • high: Most comprehensive context, higher cost, slower response
  • medium: Balanced context, cost, and latency (default)
  • low: Minimal context, lowest cost, fastest response
Responses include citations for URLs found in search results, with clickable references.

File Search Tool

File search enables quick retrieval from your knowledge base across multiple file types:
This tool requires you to first create a vector store and upload files to it. Supports various file formats including PDFs, DOCXs, TXT, and more. Results include file citations in the response.

Enhanced Reasoning

Control the depth of model reasoning for more comprehensive analysis:

Computer Use Assistant

Obiguard also supports the Computer Use Assistant (CUA) tool, which helps agents control computers or virtual machines through screenshots and actions. This feature is available for select developers as a research preview on premium tiers.
Learn More about Computer use tool here

Managing OpenAI Projects & Organizations in Obiguard

When integrating OpenAI with Obiguard, you can specify your OpenAI organization and project IDs along with your API key. This is particularly useful if you belong to multiple organizations or are accessing projects through a legacy user API key. Specifying the organization and project IDs helps you maintain better control over your access rules, usage, and costs. In Obiguard, you can add your Org & Project details by,
  1. Defining a guardrail policy
  2. Generating your virtual key for the guardrail policy
  3. Passing details in a request
Let’s explore each method in more detail.

Using Virtual Keys

When selecting OpenAI from the dropdown menu while creating a virtual key, Obiguard automatically displays optional fields for the organization ID and project ID alongside the API key field. Get your OpenAI API key from here, then add it to Obiguard to create the virtual key that can be used throughout Obiguard.

While Making a Request

You can also pass your organization and project details directly when making a request using curl, the OpenAI SDK, or the Obiguard SDK.