Setting Up Requesty in 5 Minutes with the OpenAI SDK

Getting started with AI development shouldn't be complicated. If you're already using the OpenAI SDK, you can unlock access to 160+ language models—including Claude 4, DeepSeek R1, and GPT-4o—in just 5 minutes by switching to Requesty. No need to rewrite your code or learn a new API. Let's walk through how simple it is to supercharge your existing OpenAI integration with Requesty's unified LLM gateway.

Why Use Requesty with Your OpenAI SDK?

Before we dive into the setup, let's talk about why 15,000+ developers have made the switch. When you use the OpenAI SDK directly, you're limited to OpenAI's models and pricing. But what happens when GPT-4 is down? Or when another model could handle your task at 80% less cost?

Requesty solves these problems by acting as a smart router between your code and every major LLM provider. You keep using the familiar OpenAI SDK, but gain:

  • Access to 160+ models from OpenAI, Anthropic, Google, Meta, and more

  • Automatic failover when models are unavailable

  • Smart routing that picks the best model for each request

  • Built-in caching that can reduce costs by up to 80%

  • Enterprise-grade security with guardrails and compliance features

Prerequisites: What You'll Need

To follow along with this 5-minute setup, make sure you have:

  • Python 3.7+ or Node.js 14+ installed

  • The OpenAI SDK (`pip install openai` or `npm install openai`)

  • A Requesty account (free tier available)

  • Your existing OpenAI SDK code (optional, but helpful)

Step 1: Get Your Requesty API Key (1 minute)

First, head over to app.requesty.ai/sign-up and create your free account. Once you're in:

1. Navigate to the API Keys section 2. Click "Create New Key" 3. Give it a descriptive name like "my-app-production" 4. Copy the key—you'll need it in the next step

Pro tip: Requesty lets you set spend limits on each API key, so you never have to worry about unexpected bills.

Step 2: Update Your OpenAI Client (2 minutes)

Here's where the magic happens. Instead of changing your entire codebase, you just need to update two lines. Whether you're using Python or Node.js, the process is identical.

Python Setup

Replace your existing OpenAI initialization:

```python

Before (OpenAI directly)

from openai import OpenAI client = OpenAI(api_key="sk-...")

After (Requesty)

from openai import OpenAI client = OpenAI( api_key="YOUR_REQUESTY_API_KEY", base_url="https://api.requesty.ai/v1" ) ```

Node.js Setup

```javascript // Before (OpenAI directly) const { OpenAI } = require("openai"); const openai = new OpenAI({ apiKey: "sk-..." });

// After (Requesty) const { OpenAI } = require("openai"); const openai = new OpenAI({ apiKey: "YOUR_REQUESTY_API_KEY", baseURL: "https://api.requesty.ai/v1" }); ```

That's it! Your existing code now routes through Requesty, giving you instant access to all available models.

Step 3: Make Your First Request (1 minute)

Let's test that everything is working. Here's a simple example that works exactly like before:

Python Example

```python response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "What are the benefits of using an LLM router?"}] ) print(response.choices[0].message.content) ```

Node.js Example

```javascript const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{role: "user", content: "What are the benefits of using an LLM router?"}] }); console.log(completion.choices[0].message.content); ```

Behind the scenes, Requesty is now:

  • Checking if GPT-4o is available

  • Caching the response for future identical requests

  • Applying any security guardrails you've configured

  • Tracking usage for analytics

Step 4: Unlock Advanced Features (1 minute)

Now that you're connected, you can start using Requesty's powerful features without changing your code structure.

Try Different Models

Want to use Claude 4 instead of GPT-4? Just change the model name:

```python response = client.chat.completions.create( model="claude-4", # or "deepseek-r1", "llama-3.3-70b", etc. messages=[{"role": "user", "content": "Explain quantum computing"}] ) ```

Check out the complete model list to see all your options.

Enable Smart Routing

Let Requesty automatically pick the best model for each request:

```python response = client.chat.completions.create( model="router", # Requesty's smart routing messages=[{"role": "user", "content": "Write a haiku about coding"}] ) ```

Smart routing analyzes your prompt and selects the most cost-effective model that can handle the task.

Set Up Failover Policies

Configure automatic failover in your Requesty dashboard. If GPT-4o is down, your requests automatically route to Claude 4 or another model—your code doesn't need to handle any of this complexity. Learn more about fallback policies.

Handling Common Scenarios

Working with Large Audio Files

If you're using Whisper for transcription, Requesty handles the 25MB file limit intelligently:

```python

Requesty automatically manages file chunking

transcription = client.audio.transcriptions.create( model="whisper-1", file=open("large_meeting.mp3", "rb") ) ```

Setting Custom Timeouts

For long-running requests, you can still set timeouts as usual:

```python client = OpenAI( api_key="YOUR_REQUESTY_API_KEY", base_url="https://api.requesty.ai/v1", timeout=120 # 2 minutes ) ```

Streaming Responses

Streaming works exactly as before:

```python stream = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Tell me a story"}], stream=True )

for chunk in stream: print(chunk.choices[0].delta.content or "", end="") ```

Security Best Practices

When using Requesty with the OpenAI SDK, follow these security guidelines:

  • Never expose your Requesty API key in frontend code

  • Use environment variables to store your key

  • Set up API spend limits to prevent unexpected costs

  • Enable guardrails to protect against prompt injection

  • Use request metadata to track usage by user or feature

Real-World Example: Building a Meeting Assistant

Let's put it all together with a practical example. Here's how to build a meeting assistant that transcribes audio and generates summaries:

```python from openai import OpenAI import os

Initialize Requesty client

client = OpenAI( api_key=os.getenv("REQUESTY_API_KEY"), base_url="https://api.requesty.ai/v1" )

def process_meeting(audio_file_path):

Step 1: Transcribe audio (Requesty handles file chunking)

with open(audio_file_path, "rb") as audio_file: transcription = client.audio.transcriptions.create( model="whisper-1", file=audio_file )

Step 2: Generate summary using smart routing

summary = client.chat.completions.create( model="router", # Let Requesty pick the best model messages=[ {"role": "system", "content": "You are a helpful meeting assistant."}, {"role": "user", "content": f"Summarize this meeting transcript:\n\n{transcription.text}"} ] )

Step 3: Extract action items (using a specific model)

action_items = client.chat.completions.create( model="claude-4", # Claude excels at structured extraction messages=[ {"role": "user", "content": f"Extract action items from this transcript:\n\n{transcription.text}"} ] )

return { "transcript": transcription.text, "summary": summary.choices[0].message.content, "action_items": action_items.choices[0].message.content } ```

This example showcases how Requesty enhances your workflow:

  • Automatic handling of large audio files

  • Smart routing for cost-effective summarization

  • Model-specific selection for specialized tasks

  • Built-in caching reduces costs if you process the same meeting twice

Integrating with Your Existing Tools

Requesty works seamlessly with popular development tools and frameworks:

Monitoring and Optimization

Once you're up and running, Requesty provides powerful tools to optimize your LLM usage:

  • Analytics Dashboard: See which models you're using most and their performance

  • Cost Tracking: Monitor spending in real-time with breakdowns by model and API key

  • Performance Metrics: Track latency, success rates, and cache hit rates

  • Usage Patterns: Identify opportunities to use cheaper models without sacrificing quality

For teams, enterprise features include user budgets, SSO integration, and advanced governance controls.

Troubleshooting Common Issues

Authentication Errors (401)

Make sure you're using your Requesty API key, not your OpenAI key. You can find your keys at app.requesty.ai.

Model Not Found (400)

Check the model list for exact model names. Some models require specific access tiers.

Timeout Errors

Increase the timeout parameter in your client initialization. Requesty's routing optimizations help minimize timeouts with automatic retries.

Next Steps

Congratulations! You've successfully set up Requesty with the OpenAI SDK. In just 5 minutes, you've gained access to 160+ models, automatic failover, smart routing, and potential cost savings of up to 80%.

Here's what to explore next:

1. Configure Guardrails: Set up security policies to protect against prompt injection and ensure compliance 2. Optimize Costs: Use the prompt library to manage and optimize your system prompts 3. Add Team Members: Invite your team and set up user spend limits 4. Try Dedicated Models: Explore application-specific models for coding assistants 5. Join the Community: Get help and share tips in our Discord

Conclusion

Setting up Requesty with your existing OpenAI SDK code is remarkably simple—just two lines of code to change. But the benefits are substantial: access to every major LLM, intelligent routing, automatic failover, and significant cost savings.

Whether you're building a simple chatbot or a complex AI application, Requesty gives you the flexibility to use the right model for each task without the complexity of managing multiple APIs. And because it's fully compatible with the OpenAI SDK, you can adopt it gradually, starting with just one project or even one API call.

Ready to supercharge your AI applications? Sign up for free and see why 15,000+ developers trust Requesty to handle their LLM routing. Your code stays the same, but your possibilities expand exponentially.

Have questions? Reach out to our team at support@requesty.ai or join our Discord community. We're here to help you build amazing AI applications, one API call at a time.