Documentation
Web Search
Understanding Web Search Capabilities with A4F API Services.
Current A4F Web Search Status
A4F API Services currently do not offer a built-in, universal web search plugin or feature by default across all models. This means you cannot simply append a suffix like :online
to any model ID or use a generic "web"
plugin ID to enable web search for any arbitrary model through A4F.
Future Enhancements
Temporary Solutions & Recommendations
In the meantime, you can integrate web search functionality into your applications using A4F by leveraging external APIs or specific models available through our platform that have built-in web search.
1. Using External Search APIs
You can fetch search results from dedicated search APIs and then provide this context to any LLM through A4F for summarization, question answering, or other tasks.
Popular external search APIs include:
- Brave Search API
- DuckDuckGo API (often via scraping or community libraries)
- SerpAPI
- Perplexity API (can be used for its search results)
- Google Custom Search JSON API
Conceptual Workflow:
- User's query is received by your application.
- Your application calls an external search API (e.g., SerpAPI) with the query.
- Your application receives search results (snippets, links, etc.).
- Format these results as text-based context.
- Send a new request to an A4F model (e.g.,
provider-1/chatgpt-4o-latest
) with the original query and the fetched search results as context within the prompt.
Below is a conceptual Python snippet illustrating this workflow:
2. Using Models with Built-in Web Search via A4F
Some models available through A4F, particularly those from providers like Perplexity, or specific model variants, may have inherent web search capabilities.
Examples might include (always check the A4F model list for current availability and exact naming):
- Models from Perplexity such as
perplexity/pplx-7b-online
orperplexity/pplx-70b-online
. - Specific variants like a hypothetical
provider-X/gpt-4o-web-search
if offered.
When using these models via A4F, their native web search functionality (if any) would be invoked as per the provider's original behavior. You would typically not need to manage external API calls for these specific models.
Verify Model Capabilities
Handling Search Results & Pricing
Parsing Search Results (from External APIs)
If you are integrating external search APIs, your application will be responsible for parsing the search results (which are often in JSON format) and formatting them into a text-based context suitable for an LLM. Common elements to extract include titles, snippets, and source URLs.
Pricing Considerations
Be aware of the following cost implications:
- External Search API Costs: If you use a third-party search API, you will incur costs associated with that API service, separate from your A4F usage.
- A4F Model Costs:
- When providing externally fetched search results as context to an A4F model, you will be charged by A4F for the token usage of the prompt (including the search context) and the model's completion.
- If using an A4F model with built-in web search, the pricing will be as per that specific model's rate on A4F. This rate might include a premium if the web search functionality is a specialized feature of that model.
Refer to the A4F Pricing page for model rates and the respective external search API provider for their pricing details.
Managing Search Context
When providing search results as context to an LLM via A4F (either from an external API or from a model with built-in search that returns extensive results), be mindful of the chosen LLM's context window limit.
You might need to implement strategies such as:
- Selecting only the most relevant snippets.
- Summarizing search results before passing them to the main LLM.
- Truncating context if it exceeds the model's capacity. For guidance on this, see our Message Transforms documentation.
Some models with built-in search might offer parameters to control the verbosity or "context size" of the search results they retrieve (e.g., 'low', 'medium', 'high'). If you use such a model via A4F, you would pass these parameters as part of your request according to that model's specific API.
Developer Responsibility
Pricing Documentation
For more detailed information about pricing models, refer to the official documentation:
Was this page helpful?