Developer Dashboard

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

DomainNetworkBest For
https://api.avalai.irDomestic CDNDefault choice for users in Iran with stable connectivity
https://api.avalapis.irDomestic CDNFallback for users in Iran who cannot reliably reach the primary domain
https://api.avalai.orgCloudflareUsers 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

python
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)
javascript
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);
bash
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

python
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)
javascript
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);
bash
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; use api.avalapis.ir if the primary route is unstable.
  • Outside Iran: prefer api.avalai.org for 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

bash
curl -I https://api.avalai.ir/public/models
curl -I https://api.avalapis.ir/public/models
curl -I https://api.avalai.org/public/models

If 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.