API Model for the AI Code Assistant Service
Model the API of the AI code assistant using the decisions from the preceding lesson. Define a versioned base URL and group the endpoints by completion, chat, and assisted edits. Specify the shared JSON entities, the streaming and retry behavior, and the error responses for failed requests.
We'll cover the following...
This lesson models the API of the AI code assistant using the decisions from the preceding lesson. We will define a versioned base URL, group the endpoints by the three paths including completion, chat, and assisted edits, specify the shared JSON entities, and describe how failed requests are reported. The editor client owns the editor state and the recent chat turns, and the service stores only a request record and its final state, so no conversation resource exists.
Base URL and API endpoints
The following host and version prefix are illustrative:
The API groups operations by request path, as the following map shows:
Each request carries a requestID that doubles as the key of its final-state record. Edit jobs add a jobID so the client can poll or cancel after a lost connection. Canceling changes a job's state; it does not delete the job or touch the repository.
Message format for API endpoints
A schema is a promise about what crosses the wire. Here, it protects retries, stale-response handling, and conflict detection between the editor, the API gateway, and the model workers. ...
Request inline completions
Inline completion is the latency-critical path, so the IDE sends only the context around the cursor to POST /v1/completions/inline, with a timeoutMs budget. The service returns one suggestion with a replacement range and echoes fileVersion so the client can discard stale results.
The following request carries the editor state around the cursor: