Authentication and Base URL
Run minimal AIXHUB OpenAI and Anthropic requests with the correct URL level and authentication headers.
AIXHUB exposes compatible OpenAI and Anthropic protocol surfaces. Choose one protocol for a request and keep its URL, headers, body, and model route together. An AIXHUB key is not an official OpenAI or Anthropic account credential.
| Protocol | Base URL | Complete endpoint | Authentication |
|---|---|---|---|
| OpenAI Responses | https://api.aixhub.org/v1 | https://api.aixhub.org/v1/responses | Authorization: Bearer API_KEY |
| Anthropic Messages | https://api.aixhub.org | https://api.aixhub.org/v1/messages | x-api-key plus anthropic-version: 2023-06-01 |
The complete endpoints above are for raw HTTP calls. When an SDK or client asks for a Base URL, give it the Base URL from the same row and let that library append its resource path.
Prerequisites
- Create a dedicated AIXHUB API key for this application.
- Copy one exact model ID for each protocol you intend to test from Model routes. A route can support OpenAI Responses, Anthropic Messages, or both; do not assume one model ID works with both protocols.
- Use a local terminal or controlled backend. Do not run these secret-bearing requests in public frontend code.
- Install
curlfor Bash examples. PowerShell examples use the built-inInvoke-RestMethodcommand.
Steps
Set protected environment variables
Use a disposable shell that does not already own AIXHUB_API_KEY or either model variable. On macOS or Linux Bash, prompt for the key so the real value is not stored in shell history:
read -rsp "AIXHUB API key: " AIXHUB_API_KEY && echo
export AIXHUB_API_KEY
export AIXHUB_OPENAI_MODEL="panel-openai-model-id"
export AIXHUB_ANTHROPIC_MODEL="panel-anthropic-model-id"In PowerShell on Windows:
$secureKey = Read-Host "AIXHUB API key" -AsSecureString
$env:AIXHUB_API_KEY = [System.Net.NetworkCredential]::new("", $secureKey).Password
$env:AIXHUB_OPENAI_MODEL = "panel-openai-model-id"
$env:AIXHUB_ANTHROPIC_MODEL = "panel-anthropic-model-id"Replace each visible model stand-in with a full ID whose route supports that protocol. Run only the protocol tests you need. Use a protected secret mechanism in production and clear temporary shell variables when the test ends.
Test OpenAI Bearer authentication
Bash:
curl --fail-with-body --silent --show-error \
https://api.aixhub.org/v1/responses \
--header "Authorization: Bearer $AIXHUB_API_KEY" \
--header "content-type: application/json" \
--data "{\"model\":\"$AIXHUB_OPENAI_MODEL\",\"input\":\"Reply with OK only.\"}"PowerShell:
$headers = @{ Authorization = "Bearer $env:AIXHUB_API_KEY" }
$body = @{
model = $env:AIXHUB_OPENAI_MODEL
input = "Reply with OK only."
} | ConvertTo-Json -Compress
$response = Invoke-RestMethod `
-Method Post `
-Uri "https://api.aixhub.org/v1/responses" `
-Headers $headers `
-ContentType "application/json" `
-Body $body
$response.output |
Where-Object { $_.type -eq "message" } |
ForEach-Object { $_.content } |
Where-Object { $_.type -eq "output_text" } |
Select-Object -ExpandProperty textTest Anthropic key authentication
Bash:
curl --fail-with-body --silent --show-error \
https://api.aixhub.org/v1/messages \
--header "x-api-key: $AIXHUB_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--data "{\"model\":\"$AIXHUB_ANTHROPIC_MODEL\",\"max_tokens\":16,\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK only.\"}]}"PowerShell:
$headers = @{
"x-api-key" = $env:AIXHUB_API_KEY
"anthropic-version" = "2023-06-01"
}
$body = @{
model = $env:AIXHUB_ANTHROPIC_MODEL
max_tokens = 16
messages = @(@{ role = "user"; content = "Reply with OK only." })
} | ConvertTo-Json -Depth 4 -Compress
$response = Invoke-RestMethod `
-Method Post `
-Uri "https://api.aixhub.org/v1/messages" `
-Headers $headers `
-ContentType "application/json" `
-Body $body
$response.content |
Where-Object { $_.type -eq "text" } |
Select-Object -ExpandProperty textDo not send both authentication schemes in one request. Do not paste the complete endpoint into an SDK field that already appends /responses or /v1/messages.
Clear temporary variables
After testing in the disposable Bash shell:
unset AIXHUB_API_KEY AIXHUB_OPENAI_MODEL AIXHUB_ANTHROPIC_MODELAfter testing in the disposable PowerShell session:
Remove-Item Env:AIXHUB_API_KEY, Env:AIXHUB_OPENAI_MODEL, Env:AIXHUB_ANTHROPIC_MODEL -ErrorAction SilentlyContinue
Remove-Variable headers, body, response, secureKey -ErrorAction SilentlyContinueIf those variables belonged to an existing workflow before this guide, do not delete or overwrite them. Open a separate terminal for the test, or restore the prior values from their authorized secret source.
Verification
Each minimal request should contain model text equivalent to:
OKThe PowerShell examples extract OK; the Bash commands return complete JSON containing the same text. Open AIXHUB Usage and match each request time, selected model, successful status, and, when displayed, protocol. A local response without a matching Usage record can indicate a proxy, mock, or different provider.
Troubleshooting
- 401: Confirm the environment variable is populated in the same shell. OpenAI requires
Authorization: Bearerwith one space; Anthropic requiresx-api-key. - 403: Check key state, key group, subscription, and balance.
INSUFFICIENT_BALANCEis a 403 condition, not a 429 rate limit. - 404 or
/v1/v1: A Base URL and resource path were joined at the wrong level. Return to the table and use either the Base URL or the complete endpoint as requested by the field. - 400 or model error: Copy the model ID again and confirm its route supports the selected protocol. A model problem is not always a 404.
- 429: Honor
Retry-After, lower concurrency, and retry a limited number of times. Do not rotate keys to evade a limit. - Browser CORS error: Keep the API key on your controlled backend. Relaxing browser security does not make public secret-key use safe.
For response envelopes and retry decisions, continue with the error code reference.
Next step
Use OpenAI Responses, Anthropic Messages, OpenAI Python SDK, or Anthropic Python SDK.
Official sources
Last verified: 2026-07-14