Skip to main content
Edgee provides an OpenAI-compatible API, which means you can use the official OpenAI SDKs for TypeScript and Python with Edgee. This allows you to leverage Edgee’s routing, observability, and cost tracking features without changing your existing code.

Why Use OpenAI SDK with Edgee?

  • Up to 50% Cost Reduction: Automatic token compression when enabled via headers or console
  • No Code Changes: Use your existing OpenAI SDK code as-is
  • Multi-Provider Access: Route to OpenAI, Anthropic, Google, and more through one API
  • Automatic Failover: Built-in reliability with fallback providers
  • Cost Tracking: Real-time visibility into token usage in the Edgee dashboard
  • Observability: Request tracing, compression metrics, and logging across all providers

Installation

Install the OpenAI SDK for your preferred language:

Configuration

Configure the OpenAI SDK to use Edgee’s API endpoint:

Token Usage Tracking

Access standard OpenAI token usage metrics in every response:
When compression is enabled, prompt_tokens reflects the compressed token count. View detailed compression metrics in the Edgee dashboard.

Compression & Tags via Headers

When using the OpenAI SDK with Edgee, you can control token compression and add tags using HTTP headers:

Enabling Compression

Available Headers:
HeaderTypeDescription
x-edgee-compression-model"claude", "opencode", "cursor", "codex"Compression bundle to apply (e.g. “claude” for Claude Token Compression)
x-edgee-tagsstringComma-separated tags for analytics and filtering
You can also enable compression per API key or Agent in the Edgee console. Headers override console settings for specific requests.

Advanced Usage

Function Calling (Tools)

Edgee fully supports OpenAI’s function calling interface:

Streaming Responses

Edgee supports streaming responses for real-time token delivery:

Migration from OpenAI

If you’re already using the OpenAI SDK, migrating to Edgee is straightforward:
  1. Change the base URL: Update baseURL from https://api.openai.com/v1 to https://edgee.io/v1
  2. Update API key: Use your Edgee API key instead of your OpenAI key
  3. That’s it! Your existing code will work without any other changes
All OpenAI SDK features are supported, including streaming, function calling, and response formatting. Edgee maintains full compatibility with the OpenAI API specification.