Two variables and an endpoint
Set AIAPI_API_KEY and AIAPI_MODEL on your server. Use the exact model name from the catalog. These examples contain no real credentials and do not run automatically.
- Base URL: https://aiapi.ge/v1
- Chat Completions: POST /v1/chat/completions
- Authorization: Bearer <your_API_key>
Your first request
Choose a language. Copying the example sends no request. Verify your variables, access, and pricing before running it.
# POSIX shell: set AIAPI_API_KEY and AIAPI_MODEL first.
curl --fail-with-body --max-time 60 \
https://aiapi.ge/v1/chat/completions \
-H "Authorization: Bearer $AIAPI_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{
"model": "$AIAPI_MODEL",
"messages": [
{ "role": "user", "content": "Hello!" }
]
}
JSONValidate the response
Check status, JSON structure, and the expected content. Handle empty or unexpected output. Validate proposed actions before executing them.
- Use an explicit schema.
- Handle interrupted streaming separately.
Handle failure deliberately
Apply a timeout and bounded retries. Keep useful diagnostic context without credentials or unnecessary personal data.
- 401/403: check key, expiry, permissions, and model access.
- 429: inspect limits; do not retry forever.
- 5xx or network errors: use bounded backoff.
Before going live
- Use separate development and production keys.
- Apply application-level limits.
- Monitor usage and errors.
- Test a small rollout first.
- Keep secrets out of code and logs.
