Count input tokens (LangChain - OpenAI format)

Counts the number of tokens in a Responses API request via LangChain.

POST
/langchain/v1/responses/input_tokens
AuthorizationBearer <token>

Bearer token authentication. Use your MPilot virtual-key JWT or admin JWT. Virtual keys (prefixed with sk-bf-) can also be passed here.

In: header

modelstring

Model identifier

inputstring | array<object>

Input - can be a string or array of messages

stream?boolean
instructions?string

System instructions for the model

max_output_tokens?integer
metadata?object

Empty Object

parallel_tool_calls?boolean
previous_response_id?string
reasoning?object
store?boolean
temperature?number
Range0 <= value <= 2
text?object
tool_choice?string | object
tools?array<object>
top_p?number
truncation?string
Value in"auto" | "disabled"
user?string
fallbacks?array<string>

Response Body

curl -X POST "https://loading/{AI_GATEWAY_URL}/langchain/v1/responses/input_tokens" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-4",    "input": "string"  }'
{
  "object": "string",
  "model": "string",
  "input_tokens": 0,
  "input_tokens_details": {
    "text_tokens": 0,
    "audio_tokens": 0,
    "image_tokens": 0,
    "cached_read_tokens": 0,
    "cached_write_tokens": 0
  },
  "tokens": [
    0
  ],
  "token_strings": [
    "string"
  ],
  "output_tokens": 0,
  "total_tokens": 0,
  "extra_fields": {
    "request_type": "string",
    "provider": "openai",
    "model_requested": "string",
    "model_deployment": "string",
    "latency": 0,
    "chunk_index": 0,
    "raw_request": {},
    "raw_response": {},
    "cache_debug": {
      "cache_hit": true,
      "cache_id": "string",
      "hit_type": "string",
      "requested_provider": "string",
      "requested_model": "string",
      "provider_used": "string",
      "model_used": "string",
      "input_tokens": 0,
      "threshold": 0,
      "similarity": 0
    }
  }
}
{
  "event_id": "string",
  "type": "string",
  "is_bifrost_error": true,
  "status_code": 0,
  "error": {
    "type": "string",
    "code": "string",
    "message": "string",
    "param": "string",
    "event_id": "string"
  },
  "extra_fields": {
    "provider": "openai",
    "model_requested": "string",
    "request_type": "string"
  }
}
{
  "event_id": "string",
  "type": "string",
  "is_bifrost_error": true,
  "status_code": 0,
  "error": {
    "type": "string",
    "code": "string",
    "message": "string",
    "param": "string",
    "event_id": "string"
  },
  "extra_fields": {
    "provider": "openai",
    "model_requested": "string",
    "request_type": "string"
  }
}
On this page

On this page

No Headings