SpaceXAI Releases Official Grok TypeScript SDK with Zero Dependencies, Live X Search, and Remote MCP

xAI has launched its official TypeScript SDK (@xai-official/sdk), combining Grok 4.7 multimodal capabilities with hosted server-side tools including live X sear

tau · October 4, 2026

#xAI #Grok #TypeScript #SDK #MCP #SpaceXAI

SpaceXAI Releases Official Grok TypeScript SDK with Zero Dependencies, Live X Search, and Remote MCP

SpaceXAI (xAI) has officially published its first-party TypeScript SDK package, @xai-official/sdk, to npm. Released under the open-source Apache-2.0 license, the package provides TypeScript developers with complete type definitions and optimized runtime bindings for Grok foundation models and hosted infrastructure tools, replacing community REST wrappers and manual fetch implementations.

Conceptual diagram of the official SpaceXAI TypeScript SDK package integrating Grok multimodal APIs and remote MCP server-side tools

Image source: @NFT_Chen via X / SpaceXAI

Until now, developers building on the xAI API had to manually construct request payloads and manage type definitions against the raw REST API specifications. The new official SDK delivers a single typed client capable of handling text generation, reasoning token streams with models like grok-4.7, multimodal generation (image, video, voice), and hosted tools running directly on xAI servers—including live X (Twitter) search, real-time web search, sandboxed code execution, and remote Model Context Protocol (MCP) servers.

Zero-Dependency ESM Architecture and the Official SpaceXAI Client

A primary architectural focus of @xai-official/sdk is operational simplicity and security. Built with zero runtime dependencies, the package eliminates transitive dependency risks and minimizes package footprint.

The SDK requires Node.js 22.13 or higher and operates strictly in pure ECMAScript Modules (ESM) environments. Authentication resolves automatically from the standard XAI_API_KEY environment variable. To safeguard API keys from accidental client-side leaks, the SDK explicitly blocks execution in browser and Cloudflare Workers runtime contexts by default.

Installation and client initialization require minimal setup:

# Export API key and install the package
export XAI_API_KEY="xai-your-api-key"
npm install @xai-official/sdk
import { SpaceXAI } from "@xai-official/sdk";

// Automatically detects the XAI_API_KEY environment variable
const client = new SpaceXAI();

const response = await client.responses.create({
  model: "grok-4.7",
  input: "Explain the fundamentals of quantum computing in three bullet points.",
});

console.log(response);

By standardizing on the SpaceXAI class as its primary entry point, the SDK ensures complete alignment with backend REST endpoints while providing end-to-end type safety in IDEs.

Unified Multimodal APIs and Hosted Server Tools: Live X Search and Remote MCP

Rather than limiting its scope to basic conversational chat, @xai-official/sdk spans the full suite of multimodal models and hosted server-side capabilities available across xAI infrastructure:

  • Unified Multimodal Pipeline: Direct support for the 500k-token context grok-4.7 model, alongside APIs for image generation and editing, video generation, text-to-speech (TTS), and speech-to-text audio transcription (grok-voice-transcribe-2.0).
  • Live X (Twitter) Search: Queries the live X database directly on xAI servers, feeding real-time social posts and platform context into Grok's prompt evaluation pipeline.
  • Real-Time Web Search and Code Interpreter: Combines live internet search retrieval with sandboxed Python code execution inside autonomous agent workflows.
  • Remote Model Context Protocol (MCP) Integration: Connects seamlessly with remote MCP tool servers, allowing Grok to inspect enterprise databases and external microservices through standardized context interfaces.

Granular Event-Driven Streaming and Production Adoption Considerations

For applications requiring responsive streaming interfaces or autonomous agent inspection loops, @xai-official/sdk provides a dedicated event-driven streaming interface.

Developers can subscribe to distinct event streams for raw output text, intermediate reasoning traces, and server-side tool execution payloads:

import { SpaceXAI } from "@xai-official/sdk";

const client = new SpaceXAI();

const stream = await client.responses.createStream({
  model: "grok-4.7",
  input: "Analyze current technology trends and generate a sample deployment script.",
});

// 1. Stream response text chunks
stream.on("text", (chunk) => {
  process.stdout.write(chunk);
});

// 2. Stream internal reasoning and thought tokens
stream.on("reasoning", (thought) => {
  console.log("\n[Reasoning Trace]", thought);
});

// 3. Monitor server-side tool calls (X search, web search, MCP)
stream.on("server_tool_call", (toolCall) => {
  console.log("\n[Server Tool Execution]", toolCall.name, toolCall.arguments);
});

// 4. Await final complete response object
const finalResponse = await stream.done();

When integrating the SDK into enterprise or production stacks, several operational characteristics should be considered:

  • Experimental Tag (v0.2.x): As an experimental v0.2.x release, method signatures and interface definitions may undergo refinement prior to the v1.0 milestone. Pinning exact package versions in package.json is recommended.
  • Server-Only Execution: Direct bundling into client-side browser frameworks is blocked out of the box. Client applications must invoke the SDK through backend services or server-side routes (such as Next.js Server Actions or Node.js APIs).
  • Endpoint and Model Availability: grok-4.7 is currently accessible via US regional API endpoints. Note that Grok 4.7 Fast is exclusive to Cursor and Grok Build, remaining unavailable on the public API and SDK.

Sources