Code Completion
Complete a code prefix or fill code between a prefix and suffix
Generates code at a cursor position.
prompt is the code before the cursor. Optional suffix is the code that already exists after the cursor. The returned completionText belongs between them.
Request
TypeScript SDK
cURL
Capability input
Routing controls
Code Completion model IDs are route-specific. A model ID from the OpenRouter chat catalog is not automatically valid for this endpoint.
Response
The token counts and charge above are illustrative. Read them from the live response.
Response fields
Reconstruct the file
For a simple continuation, omit suffix: