venice_create_embeddings
Generate text embeddings to enable semantic search and RAG applications by converting text into numerical representations for AI analysis.
Instructions
Generate text embeddings for semantic search and RAG
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Text or array of texts to embed | |
| model | No | Embedding model | text-embedding-ada-002 |
Implementation Reference
- src/tools/inference/index.ts:129-136 (handler)The async handler function that makes a POST request to Venice AI's /embeddings endpoint using veniceAPI, parses the response, and returns a summary of the generated embeddings.async ({ input, model }) => { const response = await veniceAPI("/embeddings", { method: "POST", body: JSON.stringify({ input, model }) }); const data = await response.json() as EmbeddingsResponse; if (!response.ok) return { content: [{ type: "text" as const, text: `Error: ${data.error?.message || response.statusText}` }] }; const embeddings = data.data || []; return { content: [{ type: "text" as const, text: `Generated ${embeddings.length} embedding(s), dimensions: ${embeddings[0]?.embedding?.length || 0}` }] }; } );
- src/tools/inference/index.ts:125-128 (schema)Zod input schema defining the parameters for the venice_create_embeddings tool: input (string or array of strings) and optional model.{ input: z.union([z.string(), z.array(z.string())]).describe("Text or array of texts to embed"), model: z.string().optional().default("text-embedding-ada-002").describe("Embedding model"), },
- src/tools/inference/index.ts:122-136 (registration)MCP server.tool registration call for the venice_create_embeddings tool, including name, description, input schema, and handler.server.tool( "venice_create_embeddings", "Generate text embeddings for semantic search and RAG", { input: z.union([z.string(), z.array(z.string())]).describe("Text or array of texts to embed"), model: z.string().optional().default("text-embedding-ada-002").describe("Embedding model"), }, async ({ input, model }) => { const response = await veniceAPI("/embeddings", { method: "POST", body: JSON.stringify({ input, model }) }); const data = await response.json() as EmbeddingsResponse; if (!response.ok) return { content: [{ type: "text" as const, text: `Error: ${data.error?.message || response.statusText}` }] }; const embeddings = data.data || []; return { content: [{ type: "text" as const, text: `Generated ${embeddings.length} embedding(s), dimensions: ${embeddings[0]?.embedding?.length || 0}` }] }; } );
- src/client/venice-api.ts:9-17 (helper)veniceAPI utility function that performs authenticated fetch requests to the Venice AI API, used by the tool handler.export async function veniceAPI(endpoint: string, options: RequestInit = {}): Promise<Response> { const url = `${BASE_URL}${endpoint}`; const headers: Record<string, string> = { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json", ...(options.headers as Record<string, string> || {}), }; return fetch(url, { ...options, headers }); }
- src/types/api-types.ts:33-37 (schema)TypeScript interface defining the structure of the embeddings API response, used in the handler.export interface EmbeddingsResponse extends VeniceAPIError { data?: Array<{ embedding?: number[]; }>; }