Welcome to the AI API Usage guide! Here, we'll walk you through how to effectively interact with our AI services using HTTP requests. Whether you're a developer or a tech enthusiast, this guide will help you get started.
Table of Contents
- Getting Started with API Calls
- Authentication & Authorization
- Request Structure
- Error Handling
- Best Practices
Getting Started with API Calls 🚀
To begin, ensure you understand the basics of HTTP methods and headers. Here's a quick overview:
- GET: Retrieve data from the server (e.g., model details).
- POST: Send data to the server (e.g., for predictions).
- HEAD: Check server metadata without downloading the body.
For detailed examples, check our API Usage Best Practices guide.
Authentication & Authorization 🔐
All API requests require valid API keys. Follow these steps:
- Sign up at https://ullrai.com/register to obtain your key.
- Include it in the request headers as
Authorization: Bearer <your_key>
. - Verify your key's validity via the Authentication Test Endpoint.
Request Structure 📦
A typical API request includes:
- Endpoint:
/v1/predict
for model predictions. - Headers:
Content-Type: application/json
andAuthorization
. - Body: JSON payload with input parameters.
Example:
{
"input": "Hello, world!",
"model": "text-generation"
}
Error Handling ⚠️
Common errors and solutions:
- 401 Unauthorized: Recheck your API key.
- 429 Too Many Requests: Use a retry-after header or reduce request frequency.
- 500 Internal Server Error: Contact support at https://ullrai.com/support.
For more, see our Error Codes Reference.
Best Practices ✅
- Always validate input data before sending requests.
- Use caching for frequent queries to reduce latency.
- Monitor usage via the Usage Dashboard.
Need further assistance? Explore our AI Overview for foundational concepts.