Developer Dashboard

Models API Reference

The Models API allows you to list available models and retrieve detailed information about specific models, including pricing, rate limits, and capabilities. AvalAI supports both OpenAI and Anthropic API formats.

Endpoints

MethodEndpointAuth RequiredDescription
GET/v1/modelsYesList all available models
GET/v1/models/{model_id}YesRetrieve a specific model
GET/public/modelsNoPublic list of models

Authentication Detection

AvalAI automatically detects the response format based on your authentication header:

Header FormatResponse Format
Authorization: Bearer API_KEYOpenAI format
x-api-key: API_KEYAnthropic format

List Models

Lists all currently available models with basic information about each one.

OpenAI Format

GET https://api.avalai.ir/v1/models

Request Headers

HeaderRequiredDescription
AuthorizationYesBearer token: Bearer YOUR_API_KEY

Example Request (OpenAI Format)

bash
curl https://api.avalai.ir/v1/models \
  -H "Authorization: Bearer $AVALAI_API_KEY"
python
from openai import OpenAI

client = OpenAI(
    api_key="your-avalai-api-key",
    base_url="https://api.avalai.ir/v1",
)

models = client.models.list()

for model in models.data:
    print(f"{model.id} - {model.owned_by}")
javascript
import { OpenAI } from "openai";

const client = new OpenAI({
  apiKey: process.env.AVALAI_API_KEY,
  baseURL: "https://api.avalai.ir/v1",
});

const models = await client.models.list();

for (const model of models.data) {
  console.log(`${model.id} - ${model.owned_by}`);
}
go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/openai/openai-go"
	"github.com/openai/openai-go/option"
)

func main() {
	client := openai.NewClient(
		option.WithAPIKey(os.Getenv("AVALAI_API_KEY")),
		option.WithBaseURL("https://api.avalai.ir/v1"),
	)

	models, err := client.Models.List(context.Background())
	if err != nil {
		panic(err)
	}

	for _, model := range models.Data {
		fmt.Printf("%s - %s\n", model.ID, model.OwnedBy)
	}
}
php
<?php

require 'vendor/autoload.php';

$apiKey = getenv('AVALAI_API_KEY');
$customBaseUrl = 'https://api.avalai.ir/v1';

$client = OpenAI::factory()
    ->withApiKey($apiKey)
    ->withBaseUri($customBaseUrl)
    ->make();

$models = $client->models()->list();

foreach ($models->data as $model) {
    echo $model->id . " - " . $model->ownedBy . "\n";
}

Response (OpenAI Format)

json
{
  "object": "list",
  "data": [
    {
      "id": "glm-5.2",
      "object": "model",
      "owned_by": "zai",
      "min_tier": 0,
      "pricing": {
        "input": 1.4,
        "cached_input": 0.26,
        "output": 4.4
      },
      "mode": "chat",
      "max_tokens": 1000000,
      "max_input_tokens": 991000,
      "max_output_tokens": 128000,
      "supports_function_calling": true,
      "supports_prompt_caching": true,
      "supports_tool_choice": true
    },
    {
      "id": "kimi-k2.7-code",
      "object": "model",
      "owned_by": "moonshot",
      "min_tier": 0,
      "pricing": {
        "input": 1.045,
        "cached_input": 0.19,
        "output": 4.4
      },
      "mode": "chat",
      "max_tokens": 262144,
      "max_input_tokens": 262144,
      "max_output_tokens": 262144,
      "supports_function_calling": true,
      "supports_tool_choice": true,
      "supports_web_search": true
    }
  ]
}

Anthropic Format

When using the x-api-key header, the response follows Anthropic's API format.

Request Headers

HeaderRequiredDescription
x-api-keyYesYour API key

Example Request (Anthropic Format)

bash
curl https://api.avalai.ir/v1/models \
  -H "x-api-key: $AVALAI_API_KEY"
python
import anthropic

client = anthropic.Anthropic(
    api_key="your-avalai-api-key",
    base_url="https://api.avalai.ir",
)

models = client.models.list()

for model in models.data:
    print(f"{model.id} - {model.display_name}")
javascript
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.AVALAI_API_KEY,
  baseURL: "https://api.avalai.ir",
});

const models = await client.models.list();

for (const model of models.data) {
  console.log(`${model.id} - ${model.display_name}`);
}

Response (Anthropic Format)

json
{
  "data": [
    {
      "id": "claude-sonnet-4-20250514",
      "created_at": "2025-02-19T00:00:00Z",
      "display_name": "Claude Sonnet 4",
      "type": "model"
    },
    {
      "id": "claude-3-5-sonnet-20241022",
      "created_at": "2024-10-22T00:00:00Z",
      "display_name": "Claude 3.5 Sonnet",
      "type": "model"
    }
  ],
  "first_id": "claude-sonnet-4-20250514",
  "has_more": true,
  "last_id": "claude-3-5-sonnet-20241022"
}

Query Parameters (Anthropic Format)

ParameterTypeRequiredDescription
after_idstringNoReturn results after this model ID
before_idstringNoReturn results before this model ID
limitnumberNoMaximum number of models to return

Public Models

A public endpoint that returns the list of available models without requiring authentication. This is useful for displaying model options to users before they authenticate.

GET https://api.avalai.ir/public/models

Example Request

bash
curl https://api.avalai.ir/public/models
python
import requests

response = requests.get("https://api.avalai.ir/public/models")
models = response.json()

for model in models["data"]:
    print(f"{model['id']} - {model['owned_by']}")
javascript
const response = await fetch("https://api.avalai.ir/public/models");
const models = await response.json();

for (const model of models.data) {
  console.log(`${model.id} - ${model.owned_by}`);
}
go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	resp, err := http.Get("https://api.avalai.ir/public/models")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var result map[string]interface{}
	json.NewDecoder(resp.Body).Decode(&result)

	data := result["data"].([]interface{})
	for _, model := range data {
		m := model.(map[string]interface{})
		fmt.Printf("%s - %s\n", m["id"], m["owned_by"])
	}
}
php
<?php

$response = file_get_contents("https://api.avalai.ir/public/models");
$models = json_decode($response, true);

foreach ($models["data"] as $model) {
    echo $model["id"] . " - " . $model["owned_by"] . "\n";
}

The response format is identical to the OpenAI format list endpoint.

Retrieve Model

Retrieves detailed information about a specific model, including AvalAI-specific metadata, pricing, and rate limits.

GET https://api.avalai.ir/v1/models/{model_id}

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesThe ID of the model to retrieve (e.g., gpt-5.5, claude-sonnet-4.6)

OpenAI Format Response

When using Authorization: Bearer header, the response includes the standard OpenAI fields plus an AvalAI-specific extra object.

Example Request (OpenAI Format)

bash
curl https://api.avalai.ir/v1/models/gpt-5.5 \
  -H "Authorization: Bearer $AVALAI_API_KEY"
python
from openai import OpenAI

client = OpenAI(
    api_key="your-avalai-api-key",
    base_url="https://api.avalai.ir/v1",
)

model = client.models.retrieve("gpt-5.5")

print(f"Model: {model.id}")
print(f"Owned by: {model.owned_by}")

# Access AvalAI extra data (available as additional fields)
print(f"Extra data: {model.model_extra}")
javascript
import { OpenAI } from "openai";

const client = new OpenAI({
  apiKey: process.env.AVALAI_API_KEY,
  baseURL: "https://api.avalai.ir/v1",
});

const model = await client.models.retrieve("gpt-5.5");

console.log(`Model: ${model.id}`);
console.log(`Owned by: ${model.owned_by}`);
go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/openai/openai-go"
	"github.com/openai/openai-go/option"
)

func main() {
	client := openai.NewClient(
		option.WithAPIKey(os.Getenv("AVALAI_API_KEY")),
		option.WithBaseURL("https://api.avalai.ir/v1"),
	)

	model, err := client.Models.Get(context.Background(), "gpt-5.5")
	if err != nil {
		panic(err)
	}

	fmt.Printf("Model: %s\n", model.ID)
	fmt.Printf("Owned by: %s\n", model.OwnedBy)
}
php
<?php

require 'vendor/autoload.php';

$apiKey = getenv('AVALAI_API_KEY');
$customBaseUrl = 'https://api.avalai.ir/v1';

$client = OpenAI::factory()
    ->withApiKey($apiKey)
    ->withBaseUri($customBaseUrl)
    ->make();

$model = $client->models()->retrieve('gpt-5.5');

echo "Model: " . $model->id . "\n";
echo "Owned by: " . $model->ownedBy . "\n";

Response (OpenAI Format with AvalAI Extra)

json
{
  "id": "gpt-5.5",
  "object": "model",
  "created": 1765622594,
  "owned_by": "openai",
  "extra": {
    "metadata": {
      "min_tier": 0,
      "mode": "chat",
      "max_tokens": 128000,
      "max_input_tokens": 1050000,
      "max_output_tokens": 128000,
      "supports_system_messages": true,
      "supports_function_calling": true,
      "supports_parallel_function_calling": true,
      "supports_vision": true,
      "supports_pdf_input": true,
      "supports_prompt_caching": true,
      "supports_tool_choice": true,
      "supports_response_schema": true
    },
    "pricing": {
      "input": 5.0,
      "cached_input": 0.5,
      "output": 30.0
    },
    "rate_limits": {
      "tiers": {
        "0": {
          "rpm": 3.0,
          "tpm": 40000.0
        },
        "1": {
          "rpm": 500.0,
          "tpm": 300000.0
        },
        "2": {
          "rpm": 5000.0,
          "tpm": 3000000.0
        },
        "3": {
          "rpm": 5000.0,
          "tpm": 4000000.0
        },
        "4": {
          "rpm": 10000.0,
          "tpm": 10000000.0
        },
        "5": {
          "rpm": 10000.0,
          "tpm": 30000000.0
        }
      },
      "current": {
        "tier": 5,
        "rpm": 10000.0,
        "tpm": 30000000.0
      }
    }
  }
}

Anthropic Format Response

When using x-api-key header, the response follows Anthropic's model format with AvalAI's extra object included.

Example Request (Anthropic Format)

bash
curl https://api.avalai.ir/v1/models/claude-sonnet-4-20250514 \
  -H "x-api-key: $AVALAI_API_KEY"
python
import anthropic

client = anthropic.Anthropic(
    api_key="your-avalai-api-key",
    base_url="https://api.avalai.ir",
)

model = client.models.retrieve("claude-sonnet-4-20250514")

print(f"Model: {model.id}")
print(f"Display name: {model.display_name}")
print(f"Created at: {model.created_at}")
javascript
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.AVALAI_API_KEY,
  baseURL: "https://api.avalai.ir",
});

const model = await client.models.retrieve("claude-sonnet-4-20250514");

console.log(`Model: ${model.id}`);
console.log(`Display name: ${model.display_name}`);
console.log(`Created at: ${model.created_at}`);

Response (Anthropic Format with AvalAI Extra)

json
{
  "id": "anthropic.claude-sonnet-4-20250514-v1:0",
  "type": "model",
  "display_name": "Anthropic.Claude Sonnet 4 20250514 V1:0",
  "created_at": "2024-01-01T00:00:00Z",
  "extra": {
    "metadata": {
      "min_tier": 1,
      "mode": "chat",
      "max_tokens": 64000,
      "max_input_tokens": 1000000,
      "max_output_tokens": 64000,
      "supports_function_calling": true,
      "supports_vision": true,
      "supports_pdf_input": true,
      "supports_prompt_caching": true,
      "supports_tool_choice": true,
      "supports_response_schema": true,
      "search_context_cost_per_query": {
        "search_context_size_high": 0.01,
        "search_context_size_low": 0.01,
        "search_context_size_medium": 0.01
      }
    },
    "pricing": {
      "input": 3.0,
      "cached_input": 1.5,
      "output": 15.0
    },
    "rate_limits": {
      "tiers": {
        "1": {
          "rpm": 10.0,
          "tpm": 80000.0
        },
        "2": {
          "rpm": 25.0,
          "tpm": 160000.0
        },
        "3": {
          "rpm": 50.0,
          "tpm": 400000.0
        },
        "4": {
          "rpm": 80.0,
          "tpm": 800000.0
        },
        "5": {
          "rpm": 100.0,
          "tpm": 1000000.0
        }
      },
      "current": {
        "tier": 5,
        "rpm": 100.0,
        "tpm": 1000000.0
      }
    }
  }
}

Response Schema

Model Object (OpenAI Format)

FieldTypeDescription
idstringThe model identifier
objectstringAlways "model"
createdintegerUnix timestamp when the model was created
owned_bystringThe organization that owns the model

Model Object (Anthropic Format)

FieldTypeDescription
idstringThe model identifier
created_atstringISO 8601 timestamp when the model was created
display_namestringHuman-readable name for the model
typestringAlways "model"

AvalAI Extra Object

The extra object is returned only on the retrieve endpoint and contains AvalAI-specific information.

Metadata Object

FieldTypeDescription
min_tierintegerMinimum tier required to use this model (0-5)
modestringModel mode. One of: chat, embedding, completion, image_generation, video_generation, audio_transcription, audio_speech, ocr, moderation, rerank, search
max_tokensintegerMaximum total tokens
max_input_tokensintegerMaximum input tokens
max_output_tokensintegerMaximum output tokens
supports_system_messagesbooleanWhether model supports system messages
supports_function_callingbooleanWhether model supports function/tool calling
supports_parallel_function_callingbooleanWhether model supports parallel function calls
supports_visionbooleanWhether model supports image inputs
supports_pdf_inputbooleanWhether model supports PDF file inputs
supports_prompt_cachingbooleanWhether model supports prompt caching
supports_tool_choicebooleanWhether model supports tool choice parameter
supports_response_schemabooleanWhether model supports structured output schemas

Pricing Object

Pricing varies by model type. The fields present depend on the model's mode.

Standard Token-Based Pricing (chat, embedding, completion models):

FieldTypeDescription
inputnumberCost per 1M input tokens (USD)
cached_inputnumberCost per 1M cached input tokens (USD)
outputnumberCost per 1M output tokens (USD)
audio_inputnumber(Optional) Cost per 1M audio input tokens (USD)
image_inputnumber(Optional) Cost per 1M image input tokens (USD)
image_outputnumber(Optional) Cost per 1M image output tokens (USD)
search_context_cost_per_queryobject(Optional) Search context pricing for search-enabled chat models

Image Generation Models (mode: image_generation):

FieldTypeDescription
output_cost_per_imagenumberBase cost per generated image (USD)
output_cost_per_image_{resolution}numberCost per image at specific resolution (e.g., 1920x1080, 4096x4096)

Video Generation Models (mode: video_generation):

FieldTypeDescription
output_cost_per_video_per_secondnumberBase cost per second of video (USD)
output_cost_per_video_per_second_{resolution}numberCost per second at specific resolution (e.g., 720x1280, 1792x1024)

Audio Transcription Models (mode: audio_transcription):

FieldTypeDescription
input_cost_per_secondnumberCost per second of audio input (USD)

Text-to-Speech Models (mode: audio_speech):

FieldTypeDescription
input_cost_per_characternumberCost per character of input text (USD)

OCR Models (mode: ocr):

FieldTypeDescription
input_cost_per_pagenumberCost per page processed (USD)

Rerank Models (mode: rerank):

FieldTypeDescription
input_cost_per_querynumberCost per rerank query (USD)

Search Models (mode: search):

FieldTypeDescription
input_cost_per_querynumberCost per search query (USD)

Rate Limits Object

FieldTypeDescription
tiersobjectRate limits for each tier (0-5)
currentobjectYour current rate limits based on your tier

Each tier contains:

FieldTypeDescription
rpmnumberRequests per minute
tpmnumberTokens per minute

The current object also includes:

FieldTypeDescription
tierintegerYour current tier level

For more information about tiers and how to upgrade, see Rate Limits.

Error Handling

Status CodeDescription
401Unauthorized - Invalid or missing API key
404Not Found - Model does not exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error