Skip to main content
POST
cURL

Overview

Create embeddings for text using OpenAI-compatible and alternative embedding models. NanoGPT supports 20+ embedding models (and this list changes over time); use GET /api/v1/embedding-models for the source-of-truth list.

Available Models

OpenAI Models

  • text-embedding-3-small - 1536 dimensions, $0.02/1M tokens - Most cost-effective with dimension reduction support
  • text-embedding-3-large - 3072 dimensions, $0.13/1M tokens - Highest performance with dimension reduction support
  • text-embedding-ada-002 - 1536 dimensions, $0.10/1M tokens - Legacy model

Alternative Models

Multilingual:
  • BAAI/bge-m3 - 1024 dimensions, $0.01/1M tokens - Multilingual support
  • jina-clip-v1 - 768 dimensions, $0.04/1M tokens - Multimodal CLIP embeddings
Language-Specific:
  • BAAI/bge-base-en-v1.5 - 768 dimensions, $0.01/1M tokens - English (base)
  • BAAI/bge-large-en-v1.5 - 1024 dimensions, $0.01/1M tokens - English optimized
  • BAAI/bge-large-zh-v1.5 - 1024 dimensions, $0.01/1M tokens - Chinese optimized
  • jina-embeddings-v2-base-en - 768 dimensions, $0.05/1M tokens - English
  • jina-embeddings-v2-base-de - 768 dimensions, $0.05/1M tokens - German
  • jina-embeddings-v2-base-zh - 768 dimensions, $0.05/1M tokens - Chinese
  • jina-embeddings-v2-base-es - 768 dimensions, $0.05/1M tokens - Spanish
Specialized:
  • BAAI/bge-reranker-large - 1024 dimensions, $0.01/1M tokens - Reranker
  • jina-embeddings-v2-base-code - 768 dimensions, $0.05/1M tokens - Code embeddings
  • Baichuan-Text-Embedding - 1024 dimensions, $0.088/1M tokens
  • netease-youdao/bce-embedding-base_v1 - 1024 dimensions, $0.02/1M tokens
  • zhipu-embedding-2 - 1024 dimensions, $0.07/1M tokens
  • Qwen/Qwen3-Embedding-0.6B - 1024 dimensions, $0.01/1M tokens - Supports dimension reduction
  • Qwen/Qwen3-Embedding-4B - 1536 dimensions, $0.03/1M tokens - Supports dimension reduction
  • Qwen/Qwen3-Embedding-8B - 1536 dimensions, $0.05/1M tokens - Supports dimension reduction
  • jina-embeddings-v3 - 1024 dimensions, $0.10/1M tokens
  • jina-embeddings-v4 - 2048 dimensions, $0.10/1M tokens
  • gemini-embedding-001 - 3072 dimensions, $0.15/1M tokens
  • doubao-embedding-large-text-240915 - 4096 dimensions, $0.10/1M tokens

Request Parameters

Response Format

Code Examples

Python with OpenAI SDK

JavaScript/TypeScript

cURL

Batch Processing

Dimension Reduction

For models that support it (text-embedding-3-small, text-embedding-3-large, Qwen/Qwen3-Embedding-0.6B, Qwen/Qwen3-Embedding-4B, Qwen/Qwen3-Embedding-8B):

Use Cases

RAG (Retrieval Augmented Generation)

Best Practices

Model Selection

  • General English text: Use text-embedding-3-small for best price/performance
  • Maximum accuracy: Use text-embedding-3-large
  • Multilingual: Use BAAI/bge-m3 or language-specific Jina models
  • Code: Use jina-embeddings-v2-base-code
  • Budget-conscious: Use BAAI models at $0.01/1M tokens

Performance Optimization

  • Batch requests: Send up to 2048 texts in a single request
  • Use dimension reduction: Reduce dimensions for faster similarity calculations when exact precision isn’t critical
  • Cache embeddings: Store computed embeddings to avoid re-processing identical texts
  • Choose appropriate models: Don’t use 3072-dimension models if 768 dimensions suffice

Cost Optimization

  • Monitor token usage: Track the usage field in responses
  • Use smaller models: Start with text-embedding-3-small before upgrading
  • Implement caching: Avoid re-embedding identical content
  • Batch processing: Reduce API call overhead

Rate Limits

Rate limits vary by endpoint and account. See Rate Limits.

Error Handling

The API returns standard HTTP status codes and OpenAI-compatible error responses: See also: Error Handling.
Common error codes:
  • 401: Invalid or missing API key
  • 400: Invalid request parameters
  • 429: Rate limit exceeded
  • 500: Server error

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Parameters for creating embeddings

input
required

Text to embed - single string or array of up to 2048 strings

model
string
required

ID of the embedding model to use

Example:

"text-embedding-3-small"

encoding_format
enum<string>
default:float

Format for embeddings

Available options:
float,
base64
dimensions
integer

Reduce embedding dimensions (only for supported models)

Example:

256

user
string

Optional identifier for tracking usage

Response

Embedding response

object
string
required

Always 'list' for embeddings

Example:

"list"

data
object[]
required

Array of embedding objects

model
string
required

Model used for embeddings

Example:

"text-embedding-3-small"

usage
object
required