bge-base-en-v1.5
Text Embeddings • baaiBAAI general embedding (Base) model that transforms any given text into a 768-dimensional vector
| Model Info | |
|---|---|
| More information | link ↗ | 
| Maximum Input Tokens | 512 | 
| Output Dimensions | 768 | 
| Batch | Yes | 
| Unit Pricing | $0.067 per M input tokens | 
Usage
Workers - TypeScript
  export interface Env {  AI: Ai;}
export default {  async fetch(request, env): Promise<Response> {
    // Can be a string or array of strings]    const stories = [      "This is a story about an orange cloud",      "This is a story about a llama",      "This is a story about a hugging emoji",    ];
    const embeddings = await env.AI.run(      "@cf/baai/bge-base-en-v1.5",      {        text: stories,      }    );
    return Response.json(embeddings);  },} satisfies ExportedHandler<Env>;Python
  import osimport requests
ACCOUNT_ID = "your-account-id"AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")
stories = [  'This is a story about an orange cloud',  'This is a story about a llama',  'This is a story about a hugging emoji']
response = requests.post(  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-base-en-v1.5",  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},  json={"text": stories})
print(response.json())curl
  curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-base-en-v1.5  \  -X POST  \  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'Parameters
* indicates a required field
Input
-  0object-  textone of required-  0string min 1The text to embed 
-  1arrayBatch of text values to embed -  itemsstring min 1The text to embed 
 
-  
 
-  
-  poolingstring default meanThe pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. 
 
-  
-  1object-  requestsarray requiredBatch of the embeddings requests to run using async-queue -  itemsobject-  textone of required-  0string min 1The text to embed 
-  1arrayBatch of text values to embed -  itemsstring min 1The text to embed 
 
-  
 
-  
-  poolingstring default meanThe pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy. 
 
-  
 
-  
 
-  
Output
-  0object-  shapearray-  itemsnumber
 
-  
-  dataarrayEmbeddings of the requested text values -  itemsarrayFloating point embedding representation shaped by the embedding model -  itemsnumber
 
-  
 
-  
-  poolingstringThe pooling method used in the embedding process. 
 
-  
-  1object-  request_idstringThe async request id that can be used to obtain the results. 
 
-  
API Schemas
The following schemas are based on JSON Schema
{    "type": "object",    "oneOf": [        {            "properties": {                "text": {                    "oneOf": [                        {                            "type": "string",                            "description": "The text to embed",                            "minLength": 1                        },                        {                            "type": "array",                            "description": "Batch of text values to embed",                            "items": {                                "type": "string",                                "description": "The text to embed",                                "minLength": 1                            },                            "maxItems": 100                        }                    ]                },                "pooling": {                    "type": "string",                    "enum": [                        "mean",                        "cls"                    ],                    "default": "mean",                    "description": "The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy."                }            },            "required": [                "text"            ]        },        {            "properties": {                "requests": {                    "type": "array",                    "description": "Batch of the embeddings requests to run using async-queue",                    "items": {                        "properties": {                            "text": {                                "oneOf": [                                    {                                        "type": "string",                                        "description": "The text to embed",                                        "minLength": 1                                    },                                    {                                        "type": "array",                                        "description": "Batch of text values to embed",                                        "items": {                                            "type": "string",                                            "description": "The text to embed",                                            "minLength": 1                                        },                                        "maxItems": 100                                    }                                ]                            },                            "pooling": {                                "type": "string",                                "enum": [                                    "mean",                                    "cls"                                ],                                "default": "mean",                                "description": "The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy."                            }                        },                        "required": [                            "text"                        ]                    }                }            },            "required": [                "requests"            ]        }    ]}{    "oneOf": [        {            "type": "object",            "contentType": "application/json",            "properties": {                "shape": {                    "type": "array",                    "items": {                        "type": "number"                    }                },                "data": {                    "type": "array",                    "description": "Embeddings of the requested text values",                    "items": {                        "type": "array",                        "description": "Floating point embedding representation shaped by the embedding model",                        "items": {                            "type": "number"                        }                    }                },                "pooling": {                    "type": "string",                    "enum": [                        "mean",                        "cls"                    ],                    "description": "The pooling method used in the embedding process."                }            }        },        {            "type": "object",            "contentType": "application/json",            "title": "Async response",            "properties": {                "request_id": {                    "type": "string",                    "description": "The async request id that can be used to obtain the results."                }            }        }    ]}Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark