content/providers/03-community-providers/36-requesty.mdx
Requesty is a unified LLM gateway that provides access to over 300 large language models from leading providers like OpenAI, Anthropic, Google, Mistral, AWS, and more. The Requesty provider for the AI SDK enables seamless integration with all these models while offering enterprise-grade advantages:
Learn more about Requesty's capabilities in the Requesty Documentation.
The Requesty provider is available in the @requesty/ai-sdk module. You can install it with:
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}> <Tab> <Snippet text="pnpm add @requesty/ai-sdk" dark /> </Tab> <Tab> <Snippet text="npm install @requesty/ai-sdk" dark /> </Tab> <Tab> <Snippet text="yarn add @requesty/ai-sdk" dark /> </Tab>
<Tab> <Snippet text="bun add @requesty/ai-sdk" dark /> </Tab> </Tabs>For security, you should set your API key as an environment variable named exactly REQUESTY_API_KEY:
# Linux/Mac
export REQUESTY_API_KEY=your_api_key_here
# Windows Command Prompt
set REQUESTY_API_KEY=your_api_key_here
# Windows PowerShell
$env:REQUESTY_API_KEY="your_api_key_here"
You can obtain your Requesty API key from the Requesty Dashboard.
You can import the default provider instance requesty from @requesty/ai-sdk:
import { requesty } from '@requesty/ai-sdk';
Alternatively, you can create a custom provider instance using createRequesty:
import { createRequesty } from '@requesty/ai-sdk';
const customRequesty = createRequesty({
apiKey: 'YOUR_REQUESTY_API_KEY',
});
Requesty supports both chat and completion models with a simple, unified interface:
// Using the default provider instance
const model = requesty('openai/gpt-4o');
// Using a custom provider instance
const customModel = customRequesty('anthropic/claude-3.5-sonnet');
You can find the full list of available models in the Requesty Models documentation.
Here are examples of using Requesty with the AI SDK:
generateTextimport { requesty } from '@requesty/ai-sdk';
import { generateText } from 'ai';
const { text } = await generateText({
model: requesty('openai/gpt-4o'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
console.log(text);
streamTextimport { requesty } from '@requesty/ai-sdk';
import { streamText } from 'ai';
const result = streamText({
model: requesty('anthropic/claude-3.5-sonnet'),
prompt: 'Write a short story about AI.',
});
for await (const chunk of result.textStream) {
console.log(chunk);
}
import { requesty } from '@requesty/ai-sdk';
import { generateText, Output } from 'ai';
import { z } from 'zod';
const { output } = await generateText({
model: requesty('openai/gpt-4o'),
output: Output.object({
schema: z.object({
recipe: z.object({
name: z.string(),
ingredients: z.array(z.string()),
steps: z.array(z.string()),
}),
}),
}),
prompt: 'Generate a recipe for chocolate chip cookies.',
});
console.log(output.recipe);
Requesty provides advanced reasoning capabilities with configurable effort levels for supported models:
import { createRequesty } from '@requesty/ai-sdk';
import { generateText } from 'ai';
const requesty = createRequesty({ apiKey: process.env.REQUESTY_API_KEY });
// Using reasoning effort
const { text, reasoning } = await generateText({
model: requesty('openai/o3-mini', {
reasoningEffort: 'medium',
}),
prompt: 'Solve this complex problem step by step...',
});
console.log('Response:', text);
console.log('Reasoning:', reasoning);
'low' - Minimal reasoning effort'medium' - Moderate reasoning effort'high' - High reasoning effort'max' - Maximum reasoning effort (Requesty-specific)"10000") - Specific token budget for reasoningopenai/o3-mini, openai/o3anthropic/claude-sonnet-4-0, other Claude reasoning modelsConfigure Requesty with custom settings:
import { createRequesty } from '@requesty/ai-sdk';
const requesty = createRequesty({
apiKey: process.env.REQUESTY_API_KEY,
baseURL: 'https://router.requesty.ai/v1',
headers: {
'Custom-Header': 'custom-value',
},
extraBody: {
custom_field: 'value',
},
});
There are three ways to pass extra body parameters to Requesty:
await streamText({
model: requesty('anthropic/claude-3.5-sonnet'),
messages: [{ role: 'user', content: 'Hello' }],
providerOptions: {
requesty: {
custom_field: 'value',
reasoning_effort: 'high',
},
},
});
const model = requesty('anthropic/claude-3.5-sonnet', {
extraBody: {
custom_field: 'value',
},
});
const requesty = createRequesty({
apiKey: process.env.REQUESTY_API_KEY,
extraBody: {
custom_field: 'value',
},
});
Requesty offers several enterprise-grade features:
99.99% Uptime SLA: Advanced routing and failover mechanisms keep your AI application online when other services fail.
Intelligent Load Balancing: Real-time performance-based routing automatically selects the best-performing providers.
Cost Optimization: Intelligent routing can reduce API costs by up to 40% while maintaining response quality.
Advanced Security: Built-in prompt injection detection, end-to-end encryption, and GDPR compliance.
Real-time Observability: Comprehensive monitoring, tracing, and analytics for all requests.
Geographic Restrictions: Comply with regional regulations through configurable geographic controls.
Model Access Control: Fine-grained control over which models and providers can be accessed.