Skip to content

Embeddings API

A knowledge base embeds and searches documents for you. When you want the raw vectors instead, to fill your own vector index or feed a retrieval pipeline you already run, call the embed query. It needs no session, workflow or knowledge base.

type Query {
embed(texts: [String!]!): EmbedResultDto!
}
type EmbedResultDto {
vectors: [[Float!]!]!
usage: EmbedUsageDto!
}
type EmbedUsageDto {
inputTokens: Int!
outputTokens: Int!
costUsd: Float!
}
RuleValue
CredentialAPI key only (X-Api-Key), from your backend. A dashboard login is refused.
Modelgemini-embedding-001, 768 dimensions: the same vectors Wetel stores for knowledge bases.
Batch size1 to 100 texts per call; more is refused, never truncated.
Ordervectors[i] belongs to texts[i].
Rate limit10 calls per minute per client IP. Send fewer, larger batches. See Rate limits.
Terminal window
curl -s -X POST https://api.wetel.dev/graphql \
-H "content-type: application/json" \
-H "x-huat-platform: customer" \
-H "x-api-key: $WETEL_API_KEY" \
-d '{
"query": "query Embed($texts: [String!]!) { embed(texts: $texts) { vectors usage { inputTokens outputTokens costUsd } } }",
"variables": { "texts": ["hello world", "second string"] }
}'

The URL is the test environment; your production URL is issued when you go live. The response has one 768-number vector per input text:

{
"data": {
"embed": {
"vectors": [
[0.0123, -0.0456, "... 768 numbers"],
[0.0789, 0.0011, "... 768 numbers"]
],
"usage": { "inputTokens": 7, "outputTokens": 0, "costUsd": 0.00000105 }
}
}
}

usage is summed over the texts in the call. outputTokens is always 0. inputTokens is estimated from the text length, not counted by the model’s tokenizer, so costUsd (at the provider’s published rate) is an estimate too: good for budgeting, not for reconciling an invoice.

  • You keep your own vector index (pgvector, a hosted vector database) outside Wetel.
  • You want vectors that are directly comparable with what Wetel stores for your knowledge bases.
  • You need embeddings in a pipeline that does not otherwise use agents or sessions.
Message or codeCause
Missing X-Api-Key header / Invalid API keyNo key, or a dashboard JWT instead of a key.
texts cannot exceed 100 entries per callSplit the batch.
texts must contain at least one entryEmpty texts.
Platform is not specified!The x-huat-platform: customer header is missing.
TOO_MANY_REQUESTSOver 10 calls a minute from one IP. See Rate-limit refusals.