Skip to main content
Glama

Create embeddings with OpenAI

openai_create_embeddings
Idempotent

Convert texts into embedding vectors for semantic search, clustering, or deduplication. Saves vectors to a JSON file and returns its path; optionally returns vectors inline for batches up to 5 texts.

Instructions

Turn texts into embedding vectors for semantic search, clustering or deduplication.

By default the vectors are written to a JSON file and only the path plus metadata are returned, because a single vector holds up to 3072 floats. Set return_vectors=true for small batches when the numbers are needed directly.

Args:

  • texts (string[], required): 1-2048 texts to embed

  • model (string): embedding model ID, defaults to OPENAI_DEFAULT_EMBEDDING_MODEL

  • dimensions (number): shorten vectors (text-embedding-3 models only)

  • return_vectors (boolean): inline the vectors, max 5 texts (default false)

  • output_path (string): absolute path of the JSON file to write

  • response_format ('markdown'|'json'): default 'markdown'

Returns (JSON format): { "model": string, "count": number, // number of vectors produced "dimensions": number, // length of each vector "file_path": string | null, // where the vectors were written "usage": { "input_tokens": number|null, "total_tokens": number|null }, "vectors": number[][] // present only when return_vectors is true }

The written JSON file has the shape: { "model": "text-embedding-3-small", "created_at": "2026-08-23T14:05:00.000Z", "count": 2, "dimensions": 1536, "items": [ { "index": 0, "text_preview": "…", "embedding": [0.0123, -0.0456] } ] }

Examples:

  • Use when: building a semantic index over documents -> texts=[...], then read the JSON file

  • Use when: comparing two sentences directly -> texts=[a, b], return_vectors=true

  • Don't use when: you just want a summary or classification (use openai_generate_text)

Error Handling:

  • "Error: return_vectors is only allowed for up to 5 texts" — lower the batch or read the file

  • "Error: OpenAI rejected the request as invalid" often means the model does not support the dimensions parameter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoEmbedding model ID. Defaults to OPENAI_DEFAULT_EMBEDDING_MODEL.
textsYesThe texts to embed, in order
dimensionsNoShorten the vectors to this many dimensions; supported by text-embedding-3 models
output_pathNoAbsolute path of the JSON file to write. Defaults to a timestamped file in OPENAI_MCP_OUTPUT_DIR.
return_vectorsNoReturn the raw vectors inline instead of only the file path. Allowed for at most 5 texts.
response_formatNoOutput format: 'markdown' or 'json'markdown

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYes
modelYes
usageYes
vectorsNo
file_pathYes
dimensionsYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses key behavioral traits: vectors are written to a JSON file by default, only the path and metadata are returned by default, inline return is limited to 5 texts, and dimensions are only supported by text-embedding-3 models. It also explains likely error messages and how to handle them, which goes well beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (summary, args, returns, examples, error handling) and front-loads the most important behavior. It is somewhat long and repeats some schema information in the Args list, but every section earns its place given the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 6-parameter tool with output-schema support, the description is complete: it covers the return JSON shape, the written file shape, default output behavior, parameter constraints, example use cases, and error scenarios. An agent has everything needed to select and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds practical meaning beyond the schema: it explains why the default avoids inline vectors (a single vector holds up to 3072 floats), clarifies the max 5 texts for return_vectors, and connects the dimensions parameter to model compatibility. Some redundancy with the schema remains.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a clear, specific action ('Turn texts into embedding vectors') and names the intended applications (semantic search, clustering, deduplication). It also differentiates from the sibling openai_generate_text by explicitly saying when not to use this tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives concrete 'Use when' scenarios, such as building a semantic index or comparing two sentences directly, and an explicit 'Don't use when' case pointing to openai_generate_text. This makes tool selection unambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piorkowskim79/openai-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server