Documentation
A4F Documentation
Welcome to the official A4F documentation. Learn how to integrate and utilize our unified AI gateway.
Introduction
A4F provides a single, standardized API endpoint to access hundreds of Large Language Models (LLMs) from various providers like OpenAI, Anthropic, Google, Mistral, and more. Simplify your AI integrations, benefit from automatic failover, optimize costs, and ensure higher availability.
Our platform acts as a proxy, forwarding your requests to the appropriate provider while offering additional features like model routing, caching, and usage tracking. Get started quickly using familiar SDKs or direct API calls.
Installation
While A4F works with many existing AI/LLM client libraries (like OpenAI's Python/JS SDKs), you might need to install specific SDKs depending on your chosen integration method. For direct API calls, no installation is typically required beyond standard HTTP clients.
Using npm (Example: OpenAI SDK)
If you plan to use the OpenAI SDK compatibility:
Using yarn (Example: OpenAI SDK)
Alternatively, using yarn:
Compatibility Note
Configuration
The primary configuration step involves setting your A4F API key and pointing your client library (if used) to the correct A4F base URL.
Remember to handle your API key securely, preferably using environment variables. Do not commit keys directly into your codebase.
Basic Usage
Once configured, making requests through A4F is similar to interacting directly with a provider's API, but you specify the desired model using the A4F model identifier format (e.g., `openai/gpt-4-turbo`, `anthropic/claude-3-opus`).
Example Code (Using OpenAI JS SDK)
Refer to the Models page for a full list of available model identifiers and their capabilities.
Advanced Features
A4F offers several advanced features beyond basic proxying:
API Options & Headers
You can pass standard API parameters like `temperature`, `max_tokens`, `top_p`, etc. A4F also supports specific headers for features like routing, caching, and metadata.
See the Parameters and Setting Headers guides for details.
Model Routing
Define fallbacks or logic to automatically route requests to different models based on availability or other criteria. This enhances resilience. Learn more in the Provider Routing documentation.
Next Steps
Explore further documentation to maximize your use of A4F: