Introduction
AI expert on any codebase, as an API
Greptile indexes large repos and then answers hard questions about them in natural language. Think of it as an AI expert on your codebase, available as an API.
Example queries:
- “How does auth work in this codebase?"
- "Generate a comment for this PR with codebase context"
- "How would I add pagination to the
/retrieve
endpoint?”
You can use the API in many ways:
- Integrate with Slack to answer codebase questions.
- Integrate with Sentry to enrich alerts with codebase context, diagnoses, and resolution steps.
- Integrate with GitHub to review PRs and comment on new issues.
We offer a growing list of first-party integrations, or you can use the API to build your own.
Order of Operations
Index repo(s)
Use POST /repositories
to submit a repo to get indexed.
Query repos
Use POST /query
to query the repo or repos in natural language and get back an answer and a list of relevant files, functions, classes etc.
Search repos
Optionally, use POST /search
to search the repo or repos in natural language and get back just the list of relevant files, functions, classes etc., not the answer.
Base URL
The base URL for all API requests is https://api.greptile.com/v2/
.
Authentication
Two tokens are required:
Greptile API key:
Include the API key in the request header: Authorization: Bearer <API_KEY>
.
You can get your API key here.
GitHub Token:
Include this header with your GitHub/Gitlab access token for operations requiring GitHub access:
X-GitHub-Token: <GITHUB_TOKEN>
.
Note: The read permissions on the GitHub/GitLab token determine which repos Greptile can reference in its answers.