// QUICKSTART
Talk to the assistant from your own code
Everything the editor plugins do is available over a small HTTP interface, so a build script, a bot or an internal tool can ask the same questions your editor asks.
Create a key from the account screen, keep it out of the repository, and send it as a bearer token.
from codepilot import Client
client = Client(api_key=os.environ["CODEPILOT_KEY"])
suggestion = client.complete(
path="services/recommendations.py",
prefix=open("services/recommendations.py").read(),
max_tokens=120,
)
print(suggestion.text, suggestion.confidence)// GUIDES
Start with a capability
Each capability has its own page: what it does, how it decides, and where it stops.
// API REFERENCE
Six endpoints, no surprises
Every endpoint takes and returns JSON, is versioned in the path, and is rate limited per key.
| Endpoint | What it does |
|---|---|
| POST /v1/complete | Return a ranked completion for a cursor position with the surrounding file as context. |
| POST /v1/review | Review a diff and return comments as suggestion blocks. |
| POST /v1/document | Generate a doc comment for one symbol in the conventions the file already uses. |
| POST /v1/refactor | Rewrite a selection against a named goal and return it as a diff. |
| GET /v1/index/status | Report how far the workspace index has progressed. |
| GET /v1/usage | Return this month’s completion count for the calling key. |
Written something with the interface? The engineering blog carries the longer walkthroughs.
Read the engineering blog