API DocsAI Model APIsEmbeddingsOpenAI

Embeddings

Convert text into vector embeddings. Compatible with the OpenAI Embeddings API — existing OpenAI SDKs work without any code changes.

Embeddings

Convert text into vector embeddings. Compatible with the OpenAI Embeddings API — existing OpenAI SDKs work without any code changes.

Supported Models

ModelProviderDimensionsBatch Limitdimensions param
gemini-embedding-001Google Vertex AI30721 (single)No
text-embedding-004Google Vertex AI7685Yes
amazon.titan-embed-text-v2:0AWS Bedrock1024 (default)1 (single)Yes (256 / 512 / 1024)

Model Details

Provider: Google Vertex AI  Dimensions: 3072  Batch Limit: 1

input must be a string — arrays are not supported. The dimensions parameter is not supported. Maximum 2048 tokens per request.

Best for RAG retrieval and knowledge base construction requiring high-precision semantic vectors.

    curl https://autorouter.top/v1/embeddings \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "gemini-embedding-001",
        "input": "AutoRouter is an enterprise-grade AI API gateway"
      }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://autorouter.top/v1"
)

resp = client.embeddings.create(
    model="gemini-embedding-001",
    input="AutoRouter is an enterprise-grade AI API gateway"
)
print(f"Dimensions: {len(resp.data[0].embedding)}")  # 3072
package main
    "context"
    "fmt"
    "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://autorouter.top/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateEmbeddings(context.Background(),
        openai.EmbeddingRequest{
            Model: "gemini-embedding-001",
            Input: []string{"AutoRouter is an enterprise-grade AI API gateway"},
        },
    )
    if err != nil {
        panic(err)
    }
    fmt.Printf("Dimensions: %d\n", len(resp.Data[0].Embedding))  // 3072
}

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://autorouter.top/v1",
});

const resp = await client.embeddings.create({
  model: "gemini-embedding-001",
  input: "AutoRouter is an enterprise-grade AI API gateway",
});

console.log(`Dimensions: ${resp.data[0].embedding.length}`); // 3072
<?php
$response = file_get_contents('https://autorouter.top/v1/embeddings', false,
    stream_context_create([
        'http' => [
            'method' => 'POST',
            'header' => implode("\r\n", [
                'Authorization: Bearer YOUR_API_KEY',
                'Content-Type: application/json',
            ]),
            'content' => json_encode([
                'model' => 'gemini-embedding-001',
                'input' => 'AutoRouter is an enterprise-grade AI API gateway',
            ]),
        ],
    ])
);

$data = json_decode($response, true);
echo 'Dimensions: ' . count($data['data'][0]['embedding']) . PHP_EOL;  // 3072

Provider: Google Vertex AI  Dimensions: 768  Batch Limit: 5

Supports batch input (array, up to 5 items). Supports dimensions compression — recommended values: 256 / 512 / 768. Maximum 2048 tokens per request.

Cost-effective for large-scale vector storage and text similarity tasks.

Single input:

curl https://autorouter.top/v1/embeddings \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": "AI is transforming the world"
  }'

Batch (up to 5 items):

curl https://autorouter.top/v1/embeddings \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": ["text one", "text two", "text three"]
  }'

Compress to 256 dimensions:

curl https://autorouter.top/v1/embeddings \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-004",
    "input": "compressed storage example",
    "dimensions": 256
  }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://autorouter.top/v1"
)

# Single input
resp = client.embeddings.create(
    model="text-embedding-004",
    input="AI is transforming the world"
)
print(f"Dimensions: {len(resp.data[0].embedding)}")  # 768

# Batch (up to 5 items)
resp = client.embeddings.create(
    model="text-embedding-004",
    input=["text one", "text two", "text three"]
)
for item in resp.data:
    print(f"[{item.index}] Dimensions: {len(item.embedding)}")  # 768

# Compress to 256 dimensions
resp = client.embeddings.create(
    model="text-embedding-004",
    input="compressed storage example",
    dimensions=256
)
print(f"Dimensions: {len(resp.data[0].embedding)}")  # 256
package main
    "context"
    "fmt"
    "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://autorouter.top/v1"
    client := openai.NewClientWithConfig(config)

    // Batch
    resp, err := client.CreateEmbeddings(context.Background(),
        openai.EmbeddingRequest{
            Model: "text-embedding-004",
            Input: []string{"text one", "text two", "text three"},
        },
    )
    if err != nil {
        panic(err)
    }
    for _, item := range resp.Data {
        fmt.Printf("[%d] Dimensions: %d\n", item.Index, len(item.Embedding))  // 768
    }

    // Compress to 256 dimensions
    resp, err = client.CreateEmbeddings(context.Background(),
        openai.EmbeddingRequest{
            Model:      "text-embedding-004",
            Input:      []string{"compressed storage example"},
            Dimensions: 256,
        },
    )
    if err != nil {
        panic(err)
    }
    fmt.Printf("Dimensions: %d\n", len(resp.Data[0].Embedding))  // 256
}

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://autorouter.top/v1",
});

// Batch (up to 5 items)
const batchResp = await client.embeddings.create({
  model: "text-embedding-004",
  input: ["text one", "text two", "text three"],
});
batchResp.data.forEach((item) => {
  console.log(`[${item.index}] Dimensions: ${item.embedding.length}`); // 768
});

// Compress to 256 dimensions
const compressedResp = await client.embeddings.create({
  model: "text-embedding-004",
  input: "compressed storage example",
  dimensions: 256,
});
console.log(`Dimensions: ${compressedResp.data[0].embedding.length}`); // 256
<?php
// Batch (up to 5 items)
$response = file_get_contents('https://autorouter.top/v1/embeddings', false,
    stream_context_create([
        'http' => [
            'method' => 'POST',
            'header' => implode("\r\n", [
                'Authorization: Bearer YOUR_API_KEY',
                'Content-Type: application/json',
            ]),
            'content' => json_encode([
                'model' => 'text-embedding-004',
                'input' => ['text one', 'text two', 'text three'],
            ]),
        ],
    ])
);
$data = json_decode($response, true);
foreach ($data['data'] as $item) {
    echo "[{$item['index']}] Dimensions: " . count($item['embedding']) . PHP_EOL;  // 768
}

// Compress to 256 dimensions
$response = file_get_contents('https://autorouter.top/v1/embeddings', false,
    stream_context_create([
        'http' => [
            'method' => 'POST',
            'header' => implode("\r\n", [
                'Authorization: Bearer YOUR_API_KEY',
                'Content-Type: application/json',
            ]),
            'content' => json_encode([
                'model'      => 'text-embedding-004',
                'input'      => 'compressed storage example',
                'dimensions' => 256,
            ]),
        ],
    ])
);
$data = json_decode($response, true);
echo 'Dimensions: ' . count($data['data'][0]['embedding']) . PHP_EOL;  // 256

Provider: AWS Bedrock  Dimensions: 1024 (default)  Batch Limit: 1

input must be a string — arrays are not supported. dimensions only accepts 256, 512, or 1024. encoding_format: base64 is not supported. Output vectors are L2-normalized; billing uses exact token counts.

Default dimensions (1024):

curl https://autorouter.top/v1/embeddings \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "amazon.titan-embed-text-v2:0",
    "input": "Hello, Bedrock!"
  }'

Specify 256 dimensions:

curl https://autorouter.top/v1/embeddings \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "amazon.titan-embed-text-v2:0",
    "input": "compressed vector example",
    "dimensions": 256
  }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://autorouter.top/v1"
)

# Default dimensions (1024)
resp = client.embeddings.create(
    model="amazon.titan-embed-text-v2:0",
    input="Hello, Bedrock!"
)
print(f"Dimensions: {len(resp.data[0].embedding)}")  # 1024

# Specify 256 dimensions
resp = client.embeddings.create(
    model="amazon.titan-embed-text-v2:0",
    input="compressed vector example",
    dimensions=256
)
print(f"Dimensions: {len(resp.data[0].embedding)}")  # 256
package main
    "context"
    "fmt"
    "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://autorouter.top/v1"
    client := openai.NewClientWithConfig(config)

    // Default dimensions (1024)
    resp, err := client.CreateEmbeddings(context.Background(),
        openai.EmbeddingRequest{
            Model: "amazon.titan-embed-text-v2:0",
            Input: []string{"Hello, Bedrock!"},
        },
    )
    if err != nil {
        panic(err)
    }
    fmt.Printf("Dimensions: %d\n", len(resp.Data[0].Embedding))  // 1024

    // Specify 256 dimensions
    resp, err = client.CreateEmbeddings(context.Background(),
        openai.EmbeddingRequest{
            Model:      "amazon.titan-embed-text-v2:0",
            Input:      []string{"compressed vector example"},
            Dimensions: 256,
        },
    )
    if err != nil {
        panic(err)
    }
    fmt.Printf("Dimensions: %d\n", len(resp.Data[0].Embedding))  // 256
}

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://autorouter.top/v1",
});

// Default dimensions (1024)
const resp = await client.embeddings.create({
  model: "amazon.titan-embed-text-v2:0",
  input: "Hello, Bedrock!",
});
console.log(`Dimensions: ${resp.data[0].embedding.length}`); // 1024

// Specify 256 dimensions
const compressedResp = await client.embeddings.create({
  model: "amazon.titan-embed-text-v2:0",
  input: "compressed vector example",
  dimensions: 256,
});
console.log(`Dimensions: ${compressedResp.data[0].embedding.length}`); // 256
<?php
// Default dimensions (1024)
$response = file_get_contents('https://autorouter.top/v1/embeddings', false,
    stream_context_create([
        'http' => [
            'method' => 'POST',
            'header' => implode("\r\n", [
                'Authorization: Bearer YOUR_API_KEY',
                'Content-Type: application/json',
            ]),
            'content' => json_encode([
                'model' => 'amazon.titan-embed-text-v2:0',
                'input' => 'Hello, Bedrock!',
            ]),
        ],
    ])
);
$data = json_decode($response, true);
echo 'Dimensions: ' . count($data['data'][0]['embedding']) . PHP_EOL;  // 1024

// Specify 256 dimensions
$response = file_get_contents('https://autorouter.top/v1/embeddings', false,
    stream_context_create([
        'http' => [
            'method' => 'POST',
            'header' => implode("\r\n", [
                'Authorization: Bearer YOUR_API_KEY',
                'Content-Type: application/json',
            ]),
            'content' => json_encode([
                'model'      => 'amazon.titan-embed-text-v2:0',
                'input'      => 'compressed vector example',
                'dimensions' => 256,
            ]),
        ],
    ])
);
$data = json_decode($response, true);
echo 'Dimensions: ' . count($data['data'][0]['embedding']) . PHP_EOL;  // 256

Error Codes

HTTP StatusError MessageCause
400input is emptyinput field is missing
400amazon titan embedding only supports a single input per requestArray passed to Titan
400gemini-embedding-001 only supports single input per requestArray passed to gemini-embedding-001
400text-embedding-004 supports up to 5 inputs per requestBatch exceeds 5 items
400unsupported bedrock embedding model: xxxUnsupported Bedrock embedding model
401Invalid tokenAPI Key is invalid or expired
429Rate limit exceededRequest rate limit exceeded
500upstream errorUpstream service error, retry later

Model Selection Guide

Use CaseRecommended ModelReason
RAG / high-precision retrievalgemini-embedding-0013072 dimensions, highest semantic accuracy
Large-scale vector storage (cost-saving)text-embedding-004 + dimensions=256Batch support + dimension compression
Text similarity / classificationtext-embedding-004768 dimensions, cost-effective, supports batching
AWS infrastructure usersamazon.titan-embed-text-v2:0Native Bedrock, exact token billing, dim compression
Multilingual scenariosAll threeNative support for Chinese, English, and more

API Reference

On this page