GreenPT Docs

Chat Completion

Create a chat completion with a GreenPT model. We recommend glm-5.2.

Create a chat completion with a GreenPT model. We recommend glm-5.2: long-context, strong at reasoning and coding, and hosted on sustainable EU infrastructure. See Models for the full list.

POST/v1/chat/completions

Authorization

bearerAuth
AuthorizationBearer <token>

Your GreenPT API key, sent as Bearer YOUR_API_KEY. See Get started for how to create one.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

text/plain

application/json

curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "glm-5.2",    "messages": [      {        "role": "user",        "content": "Hello, how are you?"      }    ]  }'
{
  "id": "string",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "string",
        "reasoning_content": "string",
        "tool_calls": [
          {}
        ]
      },
      "logprobs": {},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 9344
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "inferenceTiming": {
      "inferenceTimeMs": 0
    }
  },
  "impact": {
    "inferenceTime": {
      "total": 0,
      "unit": "ms"
    },
    "energy": {
      "total": 0,
      "unit": "Wms"
    },
    "emissions": {
      "total": 0,
      "unit": "ugCO2e"
    },
    "version": "20250922"
  }
}
{
  "error": {
    "code": 0,
    "message": "string",
    "type": "string",
    "param": "string"
  },
  "requestId": "string"
}
"Too many requests, please try again later."
{
  "error": "Service temporarily at capacity. Please retry."
}

Notes

  • Recommended model: glm-5.2. Other models (e.g. green-l, green-r, gemma4, kimi-k3, deepseek-v4-flash-0731) are available, see Models.
  • Streaming: set stream: true and consume the response as Server-Sent Events. See Chat Completion (Streaming).
  • Authorization: pass your API key in the Authorization header as Bearer YOUR_API_KEY.
  • Reasoning effort: omit reasoning_effort to keep thinking enabled (the default), or pass "none" to disable it. The accepted values differ per model and anything outside a model's set is rejected with a 400, so check the table in Reasoning effort before sending one.
  • Prompt caching: repeated prompt prefixes are served from cache and billed at a discounted input rate on supported models, with no parameter to set. The count comes back on usage.prompt_tokens_details.cached_tokens. See Prompt caching.

Compression models

Separate from the models above, GreenPT offers output-compression variants that answer with fewer output tokens at the same price per token. They are opt-in, not defaults: a plain model id such as glm-5.2 or kimi-k3 behaves exactly as documented here, and only sending a compression id changes the answer's style. See Compression models.

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

Every response includes an impact object with the environmental cost of that specific inference:

"impact": {
  "inferenceTime": { "total": 1380, "unit": "ms" },
  "energy":        { "total": 526,  "unit": "Wms" },
  "emissions":     { "total": 47,   "unit": "ugCO2e" },
  "version": "20250922"
}

emissions is in micrograms of CO₂ equivalent (µgCO₂e). The value is calculated using 1-hour datacenter-level carbon intensity data from Nodera, so it reflects what the electricity grid actually looked like at the moment your request was processed. The same prompt sent at different times of day will produce different emissions values as the share of renewable generation on the grid changes. See Carbon Calculations for the full methodology.