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.
The embed query
Section titled “The embed query”type Query { embed(texts: [String!]!): EmbedResultDto!}
type EmbedResultDto { vectors: [[Float!]!]! usage: EmbedUsageDto!}
type EmbedUsageDto { inputTokens: Int! outputTokens: Int! costUsd: Float!}| Rule | Value |
|---|---|
| Credential | API key only (X-Api-Key), from your backend. A dashboard login is refused. |
| Model | gemini-embedding-001, 768 dimensions: the same vectors Wetel stores for knowledge bases. |
| Batch size | 1 to 100 texts per call; more is refused, never truncated. |
| Order | vectors[i] belongs to texts[i]. |
| Rate limit | 10 calls per minute per client IP. Send fewer, larger batches. See Rate limits. |
Example
Section titled “Example”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 and cost
Section titled “Usage and cost”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.
When to use embed
Section titled “When to use embed”- 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.
Errors
Section titled “Errors”| Message or code | Cause |
|---|---|
Missing X-Api-Key header / Invalid API key | No key, or a dashboard JWT instead of a key. |
texts cannot exceed 100 entries per call | Split the batch. |
texts must contain at least one entry | Empty texts. |
Platform is not specified! | The x-huat-platform: customer header is missing. |
TOO_MANY_REQUESTS | Over 10 calls a minute from one IP. See Rate-limit refusals. |
See also
Section titled “See also”- Knowledge Base Guide: Wetel’s own search over your documents.
- Knowledge API reference:
embedwith the other knowledge operations. - Authentication: creating and storing API keys.