Search project code using natural language
Introduced in GitLab 18.11.
Searches indexed project code using semantic (meaning-based) similarity rather than keyword matching. Use this when you do not know the exact symbol or file name, or to discover how a behavior is implemented across the codebase.
Primary use cases:
- When you do not know the exact symbol or file path
- To see how a behavior or feature is implemented across the codebase
- To discover related implementations (clients, jobs, workers)
How to use:
- Provide a concise, specific query with concrete keywords
- Use directory_path to narrow scope (e.g. “app/services/”)
- Prefer precise intent over broad terms
Results are grouped by file. Each file includes merged line ranges with content and a relevance score (0.0-1.0). The response includes an overall confidence level (high/medium/low/unknown) based on score distribution. Results are filtered by Duo context exclusion settings.
Requires semantic code search to be enabled and indexed for the project namespace.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Query Parameters
Section titled “Query Parameters”Natural language search query (e.g. “authentication middleware”, “rate limiting logic”)
Restrict search to files under this directory path (e.g. “app/services/”). Must be a relative path — no leading slash, no .. segments.
Number of nearest neighbours to retrieve internally (default: 64). Higher values improve recall at the cost of latency.
Maximum number of results to return (default: 20).
Responses
Section titled “Responses”OK
object
object
object
Example
{ "confidence": "high", "results": [ { "path": "app/models/user.rb", "blob_id": "abc123def456", "file_url": "https://gitlab.com/group/project/-/blob/main/user.rb", "score": 0.92, "snippet_ranges": [ { "start_line": 42, "end_line": 44, "content": "def authenticate\n ...\nend", "score": 0.85 } ] } ]}Bad Request
Unauthorized
Forbidden
Not found - project not found or semantic code search unavailable
Unprocessable entity - project has no embeddings
Too many requests