How to send a request to the API?

To interact with our API, follow these steps:

  1. Obtain an API Key
    • Log in to your account and retrieve your API key from the dashboard.

      Set Up Your Environment

    • Ensure you have the required libraries installed. For Python, you can install requests if it is not already available:
pip install requests
  1. Send a Request
    • Use an HTTP GET or POST request to the appropriate API endpoint.
    • Include your API key in the request headers for authentication.

      Process the Response

    • The API returns a JSON response, which you can parse and use in your application.

Example Request in Python

import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={"Content-Type":"application/json", "Authorization": "Bearer 'YOUR_API_KEY'"},
    json={"model":"o1","messages":[{"role":"user","content":"Who are you"}]}
)
data = response.json()
print(data)
 

For more details on available endpoints, parameters, and response formats, refer to our API Documentation. If you need further assistance, contact our support team.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us