Implementation:Helicone Helicone XAI Endpoint Pricing
| Knowledge Sources | |
|---|---|
| Domains | Cost Calculation, Model Pricing |
| Last Updated | 2026-02-14 06:32 GMT |
Overview
Defines endpoint pricing configurations for xAI Grok models across xAI direct, Helicone gateway, and OpenRouter providers, including tiered pricing based on context window size.
Description
This file exports an endpoints object that maps xAI Grok model endpoint identifiers (in the format model-name:provider) to their full configuration including per-token pricing, context length limits, max completion tokens, cache multipliers, web search fees, and supported API parameters. The file covers the complete Grok model family: Grok 3, Grok 3 Mini, Grok 4, Grok 4 Fast (reasoning and non-reasoning variants), Grok 4.1 Fast, and Grok Code Fast 1. Each model is defined across up to three providers (xAI direct, Helicone gateway with pa/ prefix, and OpenRouter with x-ai/ prefix).
A key feature is tiered pricing: several models (Grok 4, Grok 4 Fast Reasoning, Grok 4.1 Fast Reasoning) have two pricing tiers based on context window usage, with a threshold at 128,000 tokens. Input above this threshold is billed at higher rates (typically 2x).
Usage
This file is consumed by Helicone's cost calculation engine to compute the cost of xAI Grok model requests. When a request is logged through the proxy, the cost system looks up the model's endpoint configuration and applies the appropriate per-token pricing tier based on the number of input tokens used.
Code Reference
Source Location
- Repository: Helicone
- File: packages/cost/models/authors/xai/endpoints.ts
Signature
import { ModelProviderName } from "../../providers";
import type { ModelProviderConfig } from "../../types";
import { GrokModelName } from "./models";
export const endpoints = {
"grok-code-fast-1:xai": { ... },
"grok-4:xai": { ... },
"grok-4-fast-reasoning:xai": { ... },
// ... more endpoints
} satisfies Partial<
Record<`${GrokModelName}:${ModelProviderName}`, ModelProviderConfig>
>;
Import
import { endpoints } from "@helicone-package/cost/models/authors/xai/endpoints";
Endpoint Configuration Schema
Each endpoint entry follows the ModelProviderConfig type:
{
providerModelId: string, // Provider-specific model identifier
provider: string, // Provider name (xai, helicone, openrouter)
author: "xai", // Model author
providerModelIdAliases?: string[], // Alternative model ID strings
pricing: [
{
threshold: number, // Token count threshold for tier (0 = base tier)
input: number, // Cost per input token
output: number, // Cost per output token
request?: number, // Per-request cost
web_search?: number, // Cost per web search source
cacheMultipliers?: {
cachedInput: number, // Multiplier for cached input tokens
},
},
],
contextLength: number, // Maximum context window size
maxCompletionTokens: number, // Maximum output tokens
supportedParameters: string[], // Supported API parameters
ptbEnabled: boolean, // Pass-through billing enabled
endpointConfigs: { "*": {} }, // Endpoint configuration (wildcard)
}
Model Endpoints
xAI Direct Provider
| Endpoint Key | Model ID | Input (per 1M) | Output (per 1M) | Context | Tiered |
|---|---|---|---|---|---|
grok-code-fast-1:xai |
grok-code-fast-1 | $0.20 | $1.50 | 256K | No |
grok-4:xai |
grok-4 | $3.00 / $6.00 | $15.00 / $30.00 | 256K | Yes (128K) |
grok-4-fast-reasoning:xai |
grok-4-fast | $0.20 / $0.40 | $0.50 / $1.00 | 2M | Yes (128K) |
grok-4-fast-non-reasoning:xai |
grok-4-fast-non-reasoning | $0.20 | $0.50 | 2M | No |
grok-4-1-fast-non-reasoning:xai |
grok-4-1-fast-non-reasoning | $0.20 | $0.50 | 2M | No |
grok-4-1-fast-reasoning:xai |
grok-4-1-fast-reasoning | $0.20 / $0.40 | $0.50 / $1.00 | 2M | Yes (128K) |
grok-3:xai |
grok-3 | $3.00 | $15.00 | 131K | No |
grok-3-mini:xai |
grok-3-mini | $0.30 | $0.50 | 131K | No |
Helicone Gateway Provider
Mirrors xAI direct pricing but with pa/ prefixed model IDs for passthrough billing:
| Endpoint Key | Model ID | Pricing |
|---|---|---|
grok-4:helicone |
pa/grk-4 | Same as grok-4:xai |
grok-4-fast-reasoning:helicone |
pa/grok-4-fast-reasoning | Same as grok-4-fast-reasoning:xai |
grok-4-fast-non-reasoning:helicone |
pa/grok-4-fast-non-reasoning | Same as grok-4-fast-non-reasoning:xai |
grok-4-1-fast-non-reasoning:helicone |
pa/grok-4-1-fast-non-reasoning | Same pricing |
grok-4-1-fast-reasoning:helicone |
pa/grok-4-1-fast-reasoning | Same pricing |
grok-code-fast-1:helicone |
pa/grok-code-fast-1 | Same pricing |
grok-3:helicone |
pa/grk-3 | Same as grok-3:xai |
grok-3-mini:helicone |
pa/grok-3-mini | Same as grok-3-mini:xai |
OpenRouter Provider
Uses x-ai/ prefixed model IDs with slightly higher pricing (approximately 5.5% markup):
| Endpoint Key | Model ID | Input (per 1M) | Output (per 1M) |
|---|---|---|---|
grok-3:openrouter |
x-ai/grok-3 | $5.28 | $26.38 |
grok-3-mini:openrouter |
x-ai/grok-3-mini | $0.63 | $4.22 |
grok-4:openrouter |
x-ai/grok-4 | $6.33 | $31.65 |
grok-code-fast-1:openrouter |
x-ai/grok-code-fast-1 | $0.21 | $1.58 |
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| GrokModelName | string union | Yes | One of the defined Grok model names (imported from ./models) |
| ModelProviderName | string union | Yes | Provider identifier (xai, helicone, openrouter) |
Outputs
| Name | Type | Description |
|---|---|---|
| endpoints | Record | Map of endpoint keys to ModelProviderConfig objects |
Usage Examples
import { endpoints } from "./endpoints";
// Look up pricing for Grok 4 on xAI
const grok4Config = endpoints["grok-4:xai"];
// grok4Config.pricing[0].input = 0.000003 ($3.00 per 1M tokens, up to 128K)
// grok4Config.pricing[1].input = 0.000006 ($6.00 per 1M tokens, over 128K)
// Check web search cost
const webSearchCost = grok4Config.pricing[0].web_search;
// 0.025 ($25.00 per 1K sources)
// Get cache discount
const cacheMultiplier = grok4Config.pricing[0].cacheMultipliers?.cachedInput;
// 0.25 (75% discount on cached input)