Expanded API Access Through Three Domains
Date: 2025-06-15
Summary
AvalAI now provides API access through three domains so developers can choose the best network path for their location and connectivity needs. All three domains expose the same API surface, use the same API keys, and share the same pricing and rate-limit behavior.
Available Domains
| Domain | Network | Best For |
|---|---|---|
https://api.avalai.ir | Domestic CDN | Default choice for users in Iran with stable connectivity |
https://api.avalapis.ir | Domestic CDN | Fallback for users in Iran who cannot reliably reach the primary domain |
https://api.avalai.org | Cloudflare | Users outside Iran or teams that need a Cloudflare-backed route |
Use one domain consistently in each environment so logs, retries, and latency measurements stay easy to compare.
How to Use
Set the domain as your base URL, then call the same endpoints you already use. Existing Chat Completions integrations can keep /v1/chat/completions; new text, reasoning, multimodal, and tool-oriented workflows should prefer /v1/responses when the selected model supports it.
Responses API
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.org/v1",
)
response = client.responses.create(
model="gpt-5.5",
instructions="You are a concise API assistant.",
input="Confirm that this AvalAI domain is reachable.",
)
print(response.output_text)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AVALAI_API_KEY,
baseURL: "https://api.avalai.org/v1",
});
const response = await client.responses.create({
model: "gpt-5.5",
instructions: "You are a concise API assistant.",
input: "Confirm that this AvalAI domain is reachable.",
});
console.log(response.output_text);curl https://api.avalai.org/v1/responses \
-H "Authorization: Bearer $AVALAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"instructions": "You are a concise API assistant.",
"input": "Confirm that this AvalAI domain is reachable."
}'Chat Completions Compatibility
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.org/v1",
)
completion = client.chat.completions.create(
model="gpt-5.5",
messages=[
{"role": "system", "content": "You are a concise API assistant."},
{"role": "user", "content": "Confirm that this AvalAI domain is reachable."},
],
)
print(completion.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AVALAI_API_KEY,
baseURL: "https://api.avalai.org/v1",
});
const completion = await client.chat.completions.create({
model: "gpt-5.5",
messages: [
{ role: "system", content: "You are a concise API assistant." },
{ role: "user", content: "Confirm that this AvalAI domain is reachable." },
],
});
console.log(completion.choices[0].message.content);curl https://api.avalai.org/v1/chat/completions \
-H "Authorization: Bearer $AVALAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{"role": "system", "content": "You are a concise API assistant."},
{"role": "user", "content": "Confirm that this AvalAI domain is reachable."}
]
}'Choosing a Domain
- Inside Iran: start with
api.avalai.ir; useapi.avalapis.irif the primary route is unstable. - Outside Iran: prefer
api.avalai.orgfor Cloudflare-backed connectivity. - Production services: configure the base URL through an environment variable such as
AVALAI_BASE_URL. - Monitoring: log the selected domain,
x-request-id, status code, and latency for every request so support can trace issues quickly.
Connectivity Check
curl -I https://api.avalai.ir/public/models
curl -I https://api.avalapis.ir/public/models
curl -I https://api.avalai.org/public/modelsIf one domain fails while another works, switch the affected environment to the healthy base URL and include the failed domain plus request time in any support ticket.