Skip to main content
Glama
phuihock
by phuihock

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
NameRequiredDescriptionDefault
inputsYes

Implementation Reference

  • 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)}"
  • 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()
  • 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:
  • Configuration for the default model used by the embeddings tool.
    "embeddings": os.getenv("MODEL_EMBEDDINGS", "sentence-transformers/all-MiniLM-L6-v2"),

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/phuihock/mcp-deeinfra'

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