GitLab Duo Chat Completions API
The GitLab Duo Chat Completions API generates Chat responses. This API is for internal use only.
Generate Chat responses
POST /chat/completions
Requests to this endpoint are proxied to the AI gateway.
Supported attributes:
Attribute | Type | Required | Description |
---|---|---|---|
content | string | Yes | Question sent to Chat. |
resource_type | string | No | Type of resource that is sent with Chat question. |
resource_id | string, integer | No | ID of the resource. Can be a resource ID (integer) or a commit hash (string). |
referer_url | string | No | Referer URL. |
client_subscription_id | string | No | Client Subscription ID. |
with_clean_history | boolean | No | Indicates if we need to reset the history before and after the request. |
project_id | integer | No | Project ID. Required if resource_type is a commit. |
additional_context | hash | No | Additional context for this chat request. See Context attributes for a list of parameters this attribute accepts. |
Context attributes
The context
attribute accepts a list of elements with the following attributes:
category
- The category of the context element. Valid values arefile
,merge_request
,issue
, orsnippet
.id
- The ID of the context element.content
- The content of the context element. The value depends on the category of the context element.metadata
- The optional additional metadata for this context element. The value depends on the category of the context element.
Example request:
curl --request POST \
--header "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
"content": "how to define class in ruby"
}' \
--url "https://gitlab.example.com/api/v4/chat/completions"
Example response:
"To define class in ruby..."
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support