For the complete documentation index, see llms.txt. This page is also available as Markdown.

Explicit Caching

Explicit Caching

post
Header parameters
AuthorizationstringRequiredExample: sk-lZxz
Body
modelstringRequired
Responses
200Success
application/json
createdintegerRequired
idstringRequired
modelstringRequired
objectstringRequired
request_idstringRequired
post/v1/chat/completions
POST /v1/chat/completions HTTP/1.1
Host: llm.onerouter.pro
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 286

{
  "model": "google/gemini-2.5-flash",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Based on the book text below:"
        },
        {
          "type": "text",
          "text": "{long_prompt}",
          "cache_control": {
            "type": "ephemeral"
          }
        },
        {
          "type": "text",
          "text": "List all main characters mentioned in the text above."
        }
      ]
    }
  ]
}
200Success
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "Based on the text provided, the main characters are:\n\n1.  **Alex**\n2.  **Dr. Anya Sharma**\n3.  **Leo**",
        "role": "assistant"
      }
    }
  ],
  "created": 1773906600,
  "id": "chatcmpl-20260319074953445439360mnRrCh5z",
  "model": "gemini-2.5-flash",
  "object": "chat.completion",
  "request_id": "2e404909cba543d080d6c62d55fbd72a",
  "usage": {
    "completion_tokens": 1135,
    "completion_tokens_details": {
      "audio_tokens": 0,
      "image_tokens": 0,
      "reasoning_tokens": 1100
    },
    "prompt_tokens": 22,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cache_write_tokens": 0,
      "cached_tokens": 0,
      "video_tokens": 0
    },
    "total_tokens": 1157
  }
}

Last updated