This tutorial only accomplishes one thing: using the minimum steps to confirm that the account, key, model and API link are all working properly. Run the short request first, and then configure Cursor, Dify, Codex or your own application.
Check before you start
- open AIFast registration page Create an account.
- Log in to the console and go to "API Tokens".
- Prepare a local environment variable that will not be submitted to the code repository.
Configuration steps
Step 1: Create API Key
Create a new token in the console. It is recommended to clearly state the purpose of the name, for example:
macbook-local-test
cursor-work
production-order-service
Different devices and projects use different Keys, which can be revoked individually if a leak is subsequently discovered, without affecting all businesses.
Step 2: Save as environment variable
macOS or Linux:
export AIFAST_API_KEY="your_API_Key"
Windows PowerShell:
$env:AIFAST_API_KEY="your_API_Key"
Step 3: Query the model
macOS or Linux:
curl https://www.aifast.hk/v1/models \
-H "Authorization: Bearer $AIFAST_API_KEY"
Windows PowerShell:
$headers = @{ Authorization = "Bearer $env:AIFAST_API_KEY" }
$models = Invoke-RestMethod -Uri "https://www.aifast.hk/v1/models" -Headers $headers
$models.data | Select-Object id
PowerShell uses $env:AIFAST_API_KEY to read environment variables; do not copy Bash syntax such as $AIFAST_API_KEY or backslash line continuations. Some Windows PowerShell versions treat curl as an alias for another command. The examples below use native Invoke-RestMethod.
Copy a model ID available to the current account from the response. Model availability may change upstream, so use the control panel and the live API response as the source of truth.
Step 4: Send short request
will YOUR_MODEL_ID Replace with the text conversation model ID returned in the previous step. macOS or Linux:
curl https://www.aifast.hk/v1/chat/completions \
-H "Authorization: Bearer $AIFAST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Reply with only: Connection successful"}],
"stream": false
}'
Windows PowerShell:
$body = @{
model = "YOUR_MODEL_ID"
messages = @(@{ role = "user"; content = "Reply with OK" })
stream = $false
} | ConvertTo-Json -Depth 5
$response = Invoke-RestMethod -Method Post -Uri "https://www.aifast.hk/v1/chat/completions" -Headers $headers -ContentType "application/json; charset=utf-8" -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$response.choices[0].message.content
This is a real model call and may incur fees; confirm the model price and token amount first. After seeing the model reply, enter the specific tool configuration.
FAQ
How to use an AI API gateway?
Register and create an independent API Key first, then request https://www.aifast.hk/v1/models Get the real model ID available for the current account, and finally use /v1/chat/completions Send a minimal request. Configure Cursor, Dify, Codex or your own application after the request is successful; do not judge long-term stability just by being able to open a web page or receiving HTTP 200 once.
curl returns HTML
Usually the web page address is requested, not the API address. Check if using:
https://www.aifast.hk/v1
Key looks correct but still 401
Copy the Key again, avoiding leading and trailing spaces. don't put Bearer The text is saved into the Key field;Bearer Should be added automatically by request header or client.
There are too many models and I don’t know which one to choose.
Just choose a text dialogue model for the first test. The request formats for images, videos, and retrieval models may be different and not suitable as the first test request for the underlying link.
Next step
| Your application or tool | Next step |
|---|---|
| Your own Python or Node.js application | OpenAI Compatible API and SDK Examples |
| Cursor | Custom API Key, Base URL and Agent troubleshooting |
| Claude Code | Claude Code API configuration |
| Codex | Codex Responses API configuration |
| Dify | Dify model provider configuration |
The success of Chat Completions does not mean that Responses API, Anthropic Messages or all tool functions have passed; follow the corresponding tutorial to continue to verify the actual required protocols.