Skip to main content
All CollectionsAPI Documentation
Afforai API Documentation
Afforai API Documentation

Explore Afforai's API Documentation for details on credit usage, authentication, rate limits, and how to purchase more credits.

Alec at Afforai avatar
Written by Alec at Afforai
Updated over a week ago

API Documentation

The Afforai's API coding documentation can be found in this page.

API Credits

Each successful API call will cost some amount of API credits, depending on the foundation model and tool used. When the API credit balance run out, the server will response with a 422 error.

Purchase more credits

1,000 credits

$19.99 ($0.019 / credit)

2,000 credits

$34.99 ($0.017 / credit)

5,000 credits

$79.99 ($0.016 / credit)

10,000 credits

$149.99 ($0.015 / credit)

Authentication and Rate Limit

Authentication

For Afforai's API, you will need to authenticate each request using the API key, which is unique to every Afforai account. Please keep your API key private and secured. You can also generate a new API key to replace the old one if needed.

Note: When you generate a new API key, the old API will become invalid which may cause a service disruption.

Rate Limit

All API endpoints are subjected to a 10 requests per second rate limit.

Models and Tools

Similar to Afforai's chatbot, you can set the foundation model and the optional AI tool for each completion request. Each model and tool have different API credit costs. API credits will only be charged on successful 200 responses.

Foundation Model

We currently support foundation models from OpenAI, Anthropic, as well as an integration with OpenRouter.

  • OpenAI GPT 3.5: This model will cost 1 credit per API call

  • OpenAI GPT 4: This model will cost 50 credits per API call

  • OpenAI GPT 4o: This model will cost 25 credits per API call

  • Claude v3 Haiku: This model will cost 3 credits per API call

  • Claude v3 Sonnet: This model will cost 30 credits per API call

  • OpenRouter Integration (Require Set up): Via OpenRouter, API users can use other models that is not offered directly on Afforai. To set up OpenRouter, please visit the Profile > Account Details > Plan Details section on the dashboard.

AI Tools

Along with the foundation model, the API also support using additional tools to give the AI more context in its answer. Each tool will also come with additional credit cost. Please reference the API Documentation to see how to use each tool.

  • Document Retrieval:

    • By providing the file IDs for the files you uploaded to Afforai, you can supplement the AI answer with information from your documents.

    • This tool will cost 2 credits per API call

  • Google Search:

    • This tool create an AI agent that will search information on the Internet to answer your questions.

    • This tool will cost 4 credits per API call

  • Semantic Scholar:

    • This tool will create an AI agent that will search on Semantic Scholar's repository of more than 200 million research papers to answer your questions.

    • This tool will cost 4 credits per API call

Did this answer your question?