Docs/Foundational Primitives/AI Gateway Router

AI Gateway Router

The AIGateway provides resilient prompt routing across multiple LLM endpoints with automatic retries, rate limiting, and fallback chains.

Fallback Routing & Rate Limiting

Select execution mode (**Gateway**, **Provider**, **Custom**) or pick models from the dropdown below:

1import { generateText, AIGateway } from '@bablusingh-dev/agentcore';
2
3const gateway = new AIGateway({
4 defaultProvider: 'openai',
5 fallbackProviders: ['openai', 'anthropic', 'deepseek', 'mistral'],
6 maxRetries: 3,
7 retryDelayMs: 1000,
8});
9
10const { text } = await generateText({
11 model: 'openai/gpt-4o',
12 prompt: 'Route this request across fallback providers automatically.',
13 gateway,
14});
15
16console.log(text);