agentskit.js
Providers

Grok provider for TypeScript AI agents

Use xAI Grok with a TypeScript AI agent using AgentsKit's OpenAI-compatible adapter, streaming, and tool calls.

import { grok } from '@agentskit/adapters'

const adapter = grok({
  apiKey: process.env.XAI_API_KEY!,
  model: 'grok-4',
})

#Options

OptionTypeDefault
apiKeystringrequired
modelstringrequired
baseUrlstringhttps://api.x.ai
includeUsagebooleanadapter default
retryRetryOptionsadapter defaults

#Model examples

grok-4 Β· grok-code-fast-1 Β· grok-4-fast.

#Env

VarPurpose
XAI_API_KEYAPI key from x.ai

#Notes

  • OpenAI-compatible /chat/completions endpoint β€” works with many OpenAI SDK idioms.
  • Streaming via SSE.

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.