Authentication
All PAIS API requests must include a personal API key in the HTTP Authorization header.
Authorization: Bearer pais-sk-YOUR_KEY_HERE
Generating a key
Keys are generated in the PAIS Portal. See Getting an API Key.
Key scope
Each API key is tied to your user identity. Rate limits and usage tracking apply per key. All requests from a key are attributed to its owner.
Using keys in common clients
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.pais.auckland.ac.nz/v1",
api_key=os.environ["PAIS_API_KEY"],
)
curl https://api.pais.auckland.ac.nz/v1/chat/completions \
-H "Authorization: Bearer ${PAIS_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"model": "llama-3-1-8b", "messages": [...]}'
from langchain_openai import ChatOpenAI
import os
llm = ChatOpenAI(
model="llama-3-1-8b",
openai_api_base="https://api.pais.auckland.ac.nz/v1",
openai_api_key=os.environ["PAIS_API_KEY"],
)
from llama_index.llms.openai_like import OpenAILike
import os
llm = OpenAILike(
model="llama-3-1-8b",
api_base="https://api.pais.auckland.ac.nz/v1",
api_key=os.environ["PAIS_API_KEY"],
is_chat_model=True,
)
Error responses
| HTTP status |
Meaning |
401 Unauthorized |
Key missing or invalid |
403 Forbidden |
Key valid but not permitted for this resource |
429 Too Many Requests |
Rate limit exceeded — see Rate Limits |