# Create an embedding

Creates a new embedding configuration for a Warehouse source.

[endpoint]
base_url = "https://warehouse.betterstack.com"
path = "/api/v1/sources/{source_id}/embeddings"
method = "POST"

[[path_param]]
name = "source_id"
description = "The ID of the Warehouse source to create the embedding for."
required = true
type = "string"

[[body_param]]
name = "embed_from"
description = "The source column name containing the text to embed."
required = true
type = "string"

[[body_param]]
name = "embed_to"
description = "The target column name where the generated embeddings will be stored."
required = true
type = "string"

[[body_param]]
name = "model"
description = "The name of the embedding model to use (e.g., `embeddinggemma:300m`)."
required = true
type = "string"

[[body_param]]
name = "dimension"
description = "The vector dimension of the embeddings to generate."
required = true
type = "integer"

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = true
type = "string"
[/endpoint]

[responses]
[[response]]
status = 201
description = '''The newly created embedding configuration.'''
body = '''{
  "data": {
    "id": "9012",
    "type": "embedding",
    "attributes": {
      "embed_from": "message",
      "embed_to": "message_embedding",
      "dimension": 512,
      "model": "embeddinggemma:300m"
    }
  }
}'''

[[response]]
status = 401
description = '''Unauthorized'''
body = '''{
  "errors": "Invalid authentication"
}'''

[[response]]
status = 404
description = '''Not Found'''
body = '''{
  "errors": "Source with the provided ID was not found"
}'''

[[response]]
status = 422
description = '''Unprocessable Entity - Validation Errors'''
body = '''{
  "errors": "Validation errors",
  "invalid_values": {
    "embed_from": ["cannot be the same as embed_to"]
  }
}'''
[/responses]

#### Example cURL

```shell
[label Example]
curl --request POST \
  --url https://warehouse.betterstack.com/api/v1/sources/123/embeddings \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "embed_from": "description",
    "embed_to": "description_embedding",
    "model": "embeddinggemma:300m",
    "dimension": 512
  }'
```
