chat

Generate or explain code

Generate, complete or explain code with top coding models. Accepts either a prompt string or an OpenAI-style messages array. Also available at /code/chat/completions.

post/code/completions

Request

  • Base URL
    https://api.krater.ai/v1
  • Auth
    HTTP bearer

Request body

promptstring

Instruction or code to complete. Alternative to messages.

modelstring

Model identifier.

languagestring

Programming language hint.

Example request

{
  "model": "anthropic/claude-sonnet-4",
  "language": "python"
}

Response

Code completion in an OpenAI chat-completion shape.

idstring required
object'chat.completion' required
createdinteger

Unix timestamp.

modelstring

Example response

{
  "id": "chatcmpl-abc123",
  "choices": [
    {
      "finish_reason": "stop"
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.