YepAPI
AI Models

Grok 4.1 Fast

xAI's fast and affordable model. 2M context window with rapid responses at a fraction of the flagship price.

POST/v1/ai/chat
$0.01/call

Overview

xAI's fast and affordable model. 2M context window with rapid responses at a fraction of the flagship price.

PropertyValue
Model IDx-ai/grok-4.1-fast
Context Window2,000,000 tokens
Max Output16,384 tokens
Input Price$0.20 / 1M tokens
Output Price$0.50 / 1M tokens

Usage

const res = await fetch('https://api.yepapi.com/v1/ai/chat', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'x-ai/grok-4.1-fast',
    messages: [{ role: 'user', content: 'Summarize the key differences between REST and GraphQL APIs.' }],
  }),
});
const { data } = await res.json();
console.log(data.message.content);
curl -X POST https://api.yepapi.com/v1/ai/chat \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "x-ai/grok-4.1-fast", "messages": [{"role": "user", "content": "Summarize the key differences between REST and GraphQL APIs."}]}'

Request Body

ParameterTypeRequiredDescriptionDefault
modelstringYesModel ID (e.g. x-ai/grok-4.1-fast)
messagesMessage[]YesArray of { role, content } objects
maxTokensnumberNoMaximum tokens in the responseModel default
temperaturenumberNoSampling temperature (0.0–2.0)1.0
topPnumberNoNucleus sampling threshold1.0
frequencyPenaltynumberNoPenalize repeated tokens0
presencePenaltynumberNoPenalize tokens already present0
streambooleanNoEnable SSE streamingfalse
Info

All AI models use the /v1/ai/chat endpoint. Specify the model with the model field.

Response

{
  "ok": true,
  "data": {
    "model": "x-ai/grok-4.1-fast",
    "message": {
      "role": "assistant",
      "content": "REST uses fixed endpoints with predefined data shapes, while GraphQL provides a single endpoint where clients specify exactly what data they need, reducing over-fetching and under-fetching."
    },
    "usage": {
      "promptTokens": 16,
      "completionTokens": 38,
      "totalTokens": 54
    }
  }
}

Streaming

Set "stream": true to receive Server-Sent Events. Each chunk contains a delta object:

data: {"delta":{"content":"REST"},"model":"x-ai/grok-4.1-fast","index":0}
data: [DONE]
Under the Hood

We handle auth, billing, and response normalization — you just send messages.

On this page