Authentication

You'll need to authenticate your requests to access any of the endpoints in the AI Library API. In this guide, we'll look at how authentication works.

Always keep your token safe and reset it if you suspect it has been compromised. Always use environment variables to store your token, and never hardcode it into your application.

Authenticate in the ailibrary python package:

Python code

import ailibrary as ai

client = ai.AILibrary(
    api_key="your-api-key"
)

All API requests should include your API key in an X-Library-Key HTTP header as follows:

Example Requests

curl https://api.ailibrary.ai/v1/generations/771 \
  -H "X-Library-Key: $AILIBRARY_API_KEY"

Was this page helpful?