# Create embeddings
URL: https://docs.munito.ai/api/createEmbedding

POST /embeddings

Turn text into vectors with an embedding model, in the request format of OpenAI's embeddings API. Set the OpenAI SDK base URL to https://api.munito.ai/inference/v1 and call `embeddings.create`.

- The embedding models are a preview. See [Embeddings](https://docs.munito.ai/features/embeddings) for the models and for access.
- Send one text or an array of at most 2,048 texts, with at most 1,200,000 characters in one request. The answer has one vector for each text, in the same order.
- Send text only. A token array gets `400`, because each model has its own tokenizer.
- Each vector is normalized to a length of 1, so a dot product gives the cosine similarity.

The answer bills the input tokens at the input price of the model. An embedding has no output tokens.

```json
{
  "operationId": "createEmbedding",
  "summary": "Create embeddings",
  "tags": [
    "Embeddings"
  ],
  "parameters": [
    {
      "name": "munito-service-tier",
      "in": "header",
      "description": "priority, standard or flex. The response names the tier that is billed; see x-ratelimit-over-limit. See [Service tiers](https://docs.munito.ai/service-tiers).",
      "schema": {
        "type": "string",
        "enum": [
          "priority",
          "standard",
          "flex"
        ],
        "default": "standard"
      }
    }
  ],
  "description": "Turn text into vectors with an embedding model, in the request format of OpenAI's embeddings API. Set the OpenAI SDK base URL to https://api.munito.ai/inference/v1 and call `embeddings.create`.\n\n- The embedding models are a preview. See [Embeddings](https://docs.munito.ai/features/embeddings) for the models and for access.\n- Send one text or an array of at most 2,048 texts, with at most 1,200,000 characters in one request. The answer has one vector for each text, in the same order.\n- Send text only. A token array gets `400`, because each model has its own tokenizer.\n- Each vector is normalized to a length of 1, so a dot product gives the cosine similarity.\n\nThe answer bills the input tokens at the input price of the model. An embedding has no output tokens.",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "model",
            "input"
          ],
          "properties": {
            "model": {
              "type": "string",
              "description": "An embedding model from GET /models, such as `google/embeddinggemma-2`."
            },
            "input": {
              "description": "The text to embed: one string, or an array of 1 to 2,048 strings, with at most 1,200,000 characters in one request. Each text must fit the context of the model.",
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            },
            "encoding_format": {
              "type": "string",
              "enum": [
                "float",
                "base64"
              ],
              "description": "`float` (the default) gives each vector as an array of numbers. `base64` gives the 32-bit floats of the vector as a base64 string, which the OpenAI SDKs decode."
            },
            "dimensions": {
              "type": "integer",
              "description": "A vector size of the model. For a shorter size, the model returns the first values of the vector, normalized again. Omit it for the full vector."
            },
            "user": {
              "type": "string",
              "description": "An identifier of your end user. Munito AI does not use it."
            }
          }
        },
        "example": {
          "model": "google/embeddinggemma-2",
          "input": [
            "task: search result | query: Which city is the capital of France?"
          ]
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "One vector for each text, in the order of the request.",
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "munito-region": {
          "description": "The jurisdiction that served the request.",
          "schema": {
            "type": "string"
          }
        },
        "munito-service-tier": {
          "description": "priority, standard or flex. The response names the tier that is billed; see x-ratelimit-over-limit.",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-over-limit": {
          "description": "yes when the request exceeded a rate limit and ran on spare capacity: a free seat of its own tier, or the flex band for background work and OCR. Fireworks sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-requests": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-requests": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-requests": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-input-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-input-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-input-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-limit-output-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-remaining-output-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        },
        "x-ratelimit-reset-output-tokens": {
          "description": "",
          "schema": {
            "type": "string"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "object",
              "data",
              "model",
              "usage"
            ],
            "properties": {
              "object": {
                "type": "string",
                "enum": [
                  "list"
                ]
              },
              "data": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "object",
                    "index",
                    "embedding"
                  ],
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "embedding"
                      ]
                    },
                    "index": {
                      "type": "integer",
                      "description": "The position of the text in the request."
                    },
                    "embedding": {
                      "description": "The vector: an array of numbers, or a base64 string.",
                      "oneOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "number"
                          }
                        },
                        {
                          "type": "string"
                        }
                      ]
                    }
                  }
                }
              },
              "model": {
                "type": "string",
                "description": "The model that made the vectors."
              },
              "usage": {
                "type": "object",
                "required": [
                  "prompt_tokens",
                  "total_tokens"
                ],
                "properties": {
                  "prompt_tokens": {
                    "type": "integer",
                    "description": "The input tokens that Munito AI bills."
                  },
                  "total_tokens": {
                    "type": "integer",
                    "description": "The same count: an embedding has no output."
                  }
                }
              }
            }
          },
          "example": {
            "object": "list",
            "data": [
              {
                "object": "embedding",
                "index": 0,
                "embedding": [
                  0.0123,
                  -0.0456,
                  0.0789
                ]
              }
            ],
            "model": "google/embeddinggemma-2",
            "usage": {
              "prompt_tokens": 16,
              "total_tokens": 16
            }
          }
        }
      }
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The request is outside the contract: an unknown field, a token array, an empty text, more than 2,048 texts or 1,200,000 characters, a vector size that the model does not have, or a text that is longer than the context of the model (`context_length_exceeded`)."
    },
    "401": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "Credentials are missing or invalid. Public model discovery also returns this error for invalid credentials."
    },
    "403": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The account or key does not permit this request."
    },
    "404": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "No embedding model with this id is available to this request."
    },
    "421": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The requested region does not permit this request on this endpoint. Read the error before a retry."
    },
    "429": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "Rate limit exceeded. Retry according to the Retry-After header."
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "An unexpected error prevents a response."
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "The model has no free capacity now, or the API holds many large answers (`server_busy`, only for a request with more than 64 texts). Retry according to the Retry-After header."
    },
    "default": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "object",
                "required": [
                  "message",
                  "type",
                  "param",
                  "code"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "param": {
                    "type": "string",
                    "nullable": true
                  },
                  "code": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        }
      },
      "headers": {
        "x-request-id": {
          "description": "The id that Munito makes for each request. Quote it to support. OpenAI sends the same header.",
          "schema": {
            "type": "string"
          }
        },
        "retry-after": {
          "description": "Seconds to wait before a retry.",
          "schema": {
            "type": "string"
          }
        },
        "www-authenticate": {
          "description": "The scheme that a 401 resource accepts.",
          "schema": {
            "type": "string"
          }
        },
        "allow": {
          "description": "The methods that a 405 resource allows.",
          "schema": {
            "type": "string"
          }
        }
      },
      "description": "An HTTP error before a response stream starts. See [Errors](https://docs.munito.ai/errors) for status codes and retry rules."
    }
  }
}
```

# Shared API schemas
{
  "securitySchemes": {
    "BearerAuth": {
      "type": "http",
      "scheme": "bearer",
      "description": "Your Munito API key."
    },
    "ApiKeyAuth": {
      "type": "apiKey",
      "in": "header",
      "name": "x-api-key",
      "description": "Your Munito API key."
    }
  }
}