embeddings
Generate vector representations of text for semantic analysis, similarity search, and AI applications using DeepInfra's API.
Instructions
Generate embeddings for a list of texts using DeepInfra OpenAI-compatible API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputs | Yes |
Implementation Reference
- src/mcp_deepinfra/server.py:85-96 (handler)The core handler function that executes the embeddings tool logic, generating embeddings for a list of input texts using the DeepInfra OpenAI-compatible API.async def embeddings(inputs: list[str]) -> str: """Generate embeddings for a list of texts using DeepInfra OpenAI-compatible API.""" model = DEFAULT_MODELS["embeddings"] try: response = await client.embeddings.create( model=model, input=inputs, ) embeddings_list = [item.embedding for item in response.data] return str(embeddings_list) except Exception as e: return f"Error generating embeddings: {type(e).__name__}: {str(e)}"
- src/mcp_deepinfra/server.py:83-84 (registration)Conditional registration of the embeddings tool using FastMCP's @app.tool() decorator based on ENABLED_TOOLS configuration.if "all" in ENABLED_TOOLS or "embeddings" in ENABLED_TOOLS: @app.tool()
- src/mcp_deepinfra/server.py:85-85 (schema)Function signature providing the input schema (inputs: list[str]) and output type (str) for automatic tool schema generation in FastMCP.async def embeddings(inputs: list[str]) -> str:
- src/mcp_deepinfra/server.py:34-34 (helper)Configuration for the default model used by the embeddings tool."embeddings": os.getenv("MODEL_EMBEDDINGS", "sentence-transformers/all-MiniLM-L6-v2"),