from openai import OpenAIclient = OpenAI( api_key="YOUR_REQUESTY_API_KEY", base_url="https://router.requesty.ai/v1",)response = client.chat.completions.create( model="openai/gpt-4o-mini", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is an LLM gateway?"}, ], max_tokens=1024, temperature=0.7,)print(response.choices[0].message.content)
import OpenAI from "openai";const client = new OpenAI({ apiKey: process.env.REQUESTY_API_KEY, baseURL: "https://router.requesty.ai/v1",});const response = await client.chat.completions.create({ model: "openai/gpt-4o-mini", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is an LLM gateway?" }, ], max_tokens: 1024, temperature: 0.7,});console.log(response.choices[0].message.content);
{ "id": "chatcmpl-abc123def456", "object": "chat.completion", "created": 1748200000, "model": "openai/gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "An LLM gateway is a unified API layer that routes requests to multiple large language model providers. It normalizes different API formats, handles failover, load balancing, and provides centralized monitoring and cost tracking across providers like OpenAI, Anthropic, Google, and others." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 24, "completion_tokens": 52, "total_tokens": 76, "cost": 0.000038 }}
Create Chat Completion
Create a chat completion using various AI models. Compatible with the OpenAI Chat Completions format.
from openai import OpenAIclient = OpenAI( api_key="YOUR_REQUESTY_API_KEY", base_url="https://router.requesty.ai/v1",)response = client.chat.completions.create( model="openai/gpt-4o-mini", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is an LLM gateway?"}, ], max_tokens=1024, temperature=0.7,)print(response.choices[0].message.content)
import OpenAI from "openai";const client = new OpenAI({ apiKey: process.env.REQUESTY_API_KEY, baseURL: "https://router.requesty.ai/v1",});const response = await client.chat.completions.create({ model: "openai/gpt-4o-mini", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is an LLM gateway?" }, ], max_tokens: 1024, temperature: 0.7,});console.log(response.choices[0].message.content);
{ "id": "chatcmpl-abc123def456", "object": "chat.completion", "created": 1748200000, "model": "openai/gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "An LLM gateway is a unified API layer that routes requests to multiple large language model providers. It normalizes different API formats, handles failover, load balancing, and provides centralized monitoring and cost tracking across providers like OpenAI, Anthropic, Google, and others." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 24, "completion_tokens": 52, "total_tokens": 76, "cost": 0.000038 }}
from openai import OpenAIclient = OpenAI( api_key="YOUR_REQUESTY_API_KEY", base_url="https://router.requesty.ai/v1",)response = client.chat.completions.create( model="openai/gpt-4o-mini", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is an LLM gateway?"}, ], max_tokens=1024, temperature=0.7,)print(response.choices[0].message.content)
import OpenAI from "openai";const client = new OpenAI({ apiKey: process.env.REQUESTY_API_KEY, baseURL: "https://router.requesty.ai/v1",});const response = await client.chat.completions.create({ model: "openai/gpt-4o-mini", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is an LLM gateway?" }, ], max_tokens: 1024, temperature: 0.7,});console.log(response.choices[0].message.content);
{ "id": "chatcmpl-abc123def456", "object": "chat.completion", "created": 1748200000, "model": "openai/gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "An LLM gateway is a unified API layer that routes requests to multiple large language model providers. It normalizes different API formats, handles failover, load balancing, and provides centralized monitoring and cost tracking across providers like OpenAI, Anthropic, Google, and others." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 24, "completion_tokens": 52, "total_tokens": 76, "cost": 0.000038 }}
Enable real-time web search by adding { "type": "web_search" } to the tools array. Requesty translates this to each provider’s native web search format automatically.
{ "model": "anthropic/claude-sonnet-4-20250514", "messages": [ { "role": "user", "content": "What are the latest news in London today?" } ], "tools": [{ "type": "web_search" }], "stream": true}
Works with Anthropic, Vertex/Gemini, OpenAI, xAI, and Perplexity models. See the Web Search guide for response format details and provider-specific behavior.