HomeDocsGrok-4 API
Chat APIs

Grok-4 API

Real-time browsing and quantitative reasoning for finance, news, and automation agents with caching and citation support. · Updated 2025-03-18

Overview

Grok-4 blends live web and API retrieval with strong analytical reasoning. It is well-suited for market monitors, news summarisation, and alerting systems that require up-to-date information and accurate calculations.

Live Browsing Request

curl -X POST "https://api.transendai.net/v1/chat/grok-4" \
  -H "Authorization: Bearer $TRANSEND_API_KEY" \
  -H "Content-Type": "application/json" \
  -d '{
    "messages": [
      { "role": "system", "content": "You are a realtime finance analyst." },
      { "role": "user", "content": "Compare Tesla and Rivian revenue growth over the last four quarters." }
    ],
    "browsing": true,
    "cache_ttl_seconds": 300
  }'
  • browsing: true enables the live data agent.
  • cache_ttl_seconds defines how long results are cached before refetching.

Response Format

{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Tesla revenue grew 9.5% QoQ... (see citations below)",
        "citations": [
          { "title": "Tesla Q4 2024 results", "url": "https://ir.tesla.com/static-files/..." },
          { "title": "Rivian shareholder letter", "url": "https://investor.rivian.com/static-files/..." }
        ],
        "attachments": [
          { "type": "csv", "name": "revenue-delta.csv", "url": "https://edge.transendai.net/data/task_grok_921.csv" }
        ]
      }
    }
  ],
  "usage": { "prompt_tokens": 2100, "completion_tokens": 380 }
}

Custom Connectors

Integrate private data sources by registering a connector:

curl -X POST "https://api.transendai.net/v1/connectors" \
  -H "Authorization: Bearer $TRANSEND_API_KEY" \
  -H "Content-Type": "application/json" \
  -d '{
    "name": "internal-pricing",
    "type": "rest",
    "config": {
      "base_url": "https://pricing.internal/api",
      "auth_header": "X-Internal-Key",
      "auth_value": "env:PRICING_KEY"
    }
  }'

Attach connectors by name in the chat request:

"connectors": ["internal-pricing", "alpha-vantage"]

Error Codes

CodeReasonAction
400Browsing enabled without connectors or network access.Ensure the workspace grants outbound browsing.
429Browsing RPM exceeded.Increase cache TTL or request higher quota.
503Upstream data provider failure.Grok falls back to cached data when available; otherwise retry.

Tips

  • Enable caching to reduce repeated data fetches for dashboards.
  • Stream responses (stream: true) to surface partial tables early.
  • Monitor browsing usage via the billing dashboard to control third-party API costs.

Related Links