GreenPT Docs

Chat Completion Streaming

Stream chat completions with the GreenPT model for real-time responses.

POST

Stream chat completions with the GreenPT model for real-time responses.

Long Kimi generations

Use stream: true for long Kimi reasoning or generation requests. Streaming is the preferred mode because it delivers partial output while the model is working. Keep reading events until the final data: [DONE] sentinel.

Endpoint

POST https://api.greenpt.ai/v1/chat/completions

Request body

Required and optional parameters.

ParameterTypeRequiredDescription
modelstringYesID of the model to use (e.g., "green-l", "glm-5.2", "deepseek-v4-flash-0731"). See Models.
messagesarrayYesArray of message objects with role and content.
streambooleanYesMust be set to true for streaming responses.

Example request

curl https://api.greenpt.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your_api_key" \
  -d '{
    "model": "kimi-k3",
    "messages": [
      {
        "role": "user",
        "content": "Write a detailed technical migration plan."
      }
    ],
    "stream": true
  }'

Streaming response format

The response is a text stream of Server-Sent Events (SSE). Each event is a JSON object prefixed with data: , terminated by a final data: [DONE] sentinel.

data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"kimi-k3","choices":[{"index":0,"delta":{"role":"assistant","content":"Start"},"finish_reason":null}]}

data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"kimi-k3","choices":[{"index":0,"delta":{"content":" by inventorying"},"finish_reason":null}]}

data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"kimi-k3","choices":[{"index":0,"delta":{"content":" the current system."},"finish_reason":null}]}

data: {"id":"cmpl-12345","object":"chat.completion.chunk","created":1699044968,"model":"kimi-k3","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Reading the stream

Each chat.completion.chunk carries an incremental delta. Concatenate delta.content across chunks to assemble the full assistant message. The final non-[DONE] chunk includes a finish_reason ("stop", "length", etc.) and no further content.

Rate limits

Requests are limited per account (shared across all your API keys): 600 requests per 15-minute window, and shared across every GreenPT API endpoint rather than counted separately per endpoint. Exceeding it returns 429 Too many requests, please try again later. with RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and Retry-After response headers — read RateLimit-Remaining to track your usage against the current window.

503 at high load

Independent of your own rate limit, this endpoint can also return 503 with {"error": "Service temporarily at capacity. Please retry."} and a Retry-After: 5 header when demand exceeds available model capacity. Retry after the delay.

Sustainability impact

The final chunk (the one that also carries usage) includes an impact object with the environmental cost of the inference:

data: {"id":"cmpl-12345","object":"chat.completion.chunk","model":"green-l",
  "choices":[{"index":0,"delta":{},"finish_reason":"stop"}],
  "usage":{"prompt_tokens":10,"completion_tokens":22,"total_tokens":32},
  "impact":{
    "inferenceTime": { "total": 1380, "unit": "ms" },
    "energy":        { "total": 526,  "unit": "Wms" },
    "emissions":     { "total": 47,   "unit": "ugCO2e" },
    "version": "20250922"
  }
}

data: [DONE]

emissions is in micrograms of CO₂ equivalent (µgCO₂e), calculated using 1-hour datacenter-level carbon intensity data from Nodera. The value reflects the actual grid conditions at the time of the request, so the same prompt can produce different figures at different times of day. See Carbon Calculations for the full methodology.

Token usage

Usage arrives once, on the final chunk, the one with an empty choices array. No earlier chunk carries it, so read the counts there rather than accumulating across chunks.

{
  "object": "chat.completion.chunk",
  "choices": [],
  "usage": {
    "prompt_tokens": 9372,
    "completion_tokens": 8,
    "total_tokens": 9380,
    "prompt_tokens_details": { "cached_tokens": 9344 },
    "completion_tokens_details": { "reasoning_tokens": 13 }
  }
}

Prompt-cache hits are reported on the same field as a non-streaming response, usage.prompt_tokens_details.cached_tokens. See Prompt caching.

You do not need to set stream_options: {"include_usage": true}. The usage chunk is always sent.

Models

See the full list of available models on the Models page. Examples used throughout these docs are glm-5.2 and kimi-k3.

Compression models

Separate from the models above, GreenPT offers output-compression variants that stream a shorter answer at the same price per token. They are opt-in, not defaults: nothing changes unless you send a compression model id instead of the base id. See Compression models.

On this page