Skip to main content

Overview

Retrieve detailed information about a specific request using its unique identifier. This endpoint returns comprehensive data about both the request and response, including metadata, token usage, costs, and custom properties.

Endpoint

method
string
required
GET
url
string
required
/v1/request/

Authentication

Requires API key authentication via the Authorization header:
Authorization: Bearer YOUR_API_KEY

Path Parameters

requestId
string
required
The unique identifier of the request to retrieve

Query Parameters

includeBody
boolean
default:"false"
Whether to include the full request and response bodies in the response.
  • true - Includes complete request/response payloads
  • false - Returns metadata only (faster, smaller response)

Response

Returns a single request object with detailed information.
data
object
The request object
error
string
Error message if the request failed

Examples

Basic Request

Retrieve a request without body data:
curl -X GET "https://api.helicone.ai/v1/request/req_123abc" \
  -H "Authorization: Bearer YOUR_API_KEY"

Request with Full Body

Retrieve a request including complete request and response bodies:
curl -X GET "https://api.helicone.ai/v1/request/req_123abc?includeBody=true" \
  -H "Authorization: Bearer YOUR_API_KEY"

Using in Code

const response = await fetch(
  'https://api.helicone.ai/v1/request/req_123abc?includeBody=true',
  {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  }
);

const result = await response.json();

if (result.data) {
  console.log('Request Model:', result.data.model);
  console.log('Total Tokens:', result.data.total_tokens);
  console.log('Cost:', result.data.cost);
  console.log('Latency:', result.data.delay_ms, 'ms');
}

Response Example

{
  "data": {
    "request_id": "req_123abc",
    "request_created_at": "2024-01-15T10:30:00.000Z",
    "request_path": "/v1/chat/completions",
    "request_model": "gpt-4",
    "request_user_id": "user_456",
    "request_properties": {
      "environment": "production",
      "version": "1.2.3"
    },
    "request_body": {
      "model": "gpt-4",
      "messages": [
        {
          "role": "user",
          "content": "What is the capital of France?"
        }
      ],
      "temperature": 0.7
    },
    "response_id": "res_789def",
    "response_created_at": "2024-01-15T10:30:02.341Z",
    "response_status": 200,
    "response_model": "gpt-4-0613",
    "response_body": {
      "id": "chatcmpl-123",
      "object": "chat.completion",
      "created": 1705317002,
      "model": "gpt-4-0613",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "The capital of France is Paris."
          },
          "finish_reason": "stop"
        }
      ],
      "usage": {
        "prompt_tokens": 15,
        "completion_tokens": 8,
        "total_tokens": 23
      }
    },
    "provider": "OPENAI",
    "model": "gpt-4-0613",
    "target_url": "https://api.openai.com/v1/chat/completions",
    "delay_ms": 2341,
    "time_to_first_token": 234,
    "total_tokens": 23,
    "prompt_tokens": 15,
    "completion_tokens": 8,
    "cost": 0.00069,
    "costUSD": 0.00069,
    "feedback_rating": true,
    "scores": {
      "accuracy": 0.95
    },
    "properties": {
      "environment": "production",
      "version": "1.2.3"
    },
    "cache_enabled": false,
    "updated_at": "2024-01-15T10:30:02.500Z"
  },
  "error": null
}

Error Responses

Request Not Found

{
  "data": null,
  "error": "Request not found"
}

Unauthorized

{
  "data": null,
  "error": "Unauthorized: Invalid API key"
}

Use Cases

  • Debug specific requests: Investigate issues with particular API calls
  • Audit trail: Review the complete history of a request and response
  • Cost analysis: Check token usage and costs for specific requests
  • Performance monitoring: Analyze latency and time-to-first-token metrics
  • Quality assurance: Review requests with feedback or evaluation scores
  • Compliance: Export specific requests for compliance or auditing purposes

Notes

  • The includeBody parameter significantly increases response size but is necessary for debugging
  • Request bodies may contain sensitive data - ensure proper access controls
  • Asset URLs (if present) are pre-signed and time-limited
  • The cost field is calculated based on token usage and current provider pricing
  • Some fields may be null depending on the request type and provider