GMI Cloud
The GMI Cloud provider offers access to open-weight language models through GMI Cloud's GPU inference platform, over an OpenAI-compatible API.
Start with AI Gateway for models in its catalog (recommended), or use @ai-sdk/gmicloud to connect directly to GMI Cloud.
import { generateText } from 'ai';
const { text } = await generateText({
model: 'anthropic/claude-sonnet-5.5',
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
console.log(text);Using AI Gateway
The AI SDK uses AI Gateway by default for model strings. Gateway provides access to models across providers through a single API key, with usage and cost tracking. Install ai:
pnpm add ainpm install aiyarn add aibun add aiSet an AI Gateway API key in your environment:
export AI_GATEWAY_API_KEY=your_api_key_hereVercel deployments can also use OIDC authentication. See the AI Gateway provider documentation for configuration and the model catalog for available models.
The example sets providerOptions.gateway.order to ['gmicloud']. This sends the request to GMI Cloud first, then falls back to other available providers of the same model if GMI Cloud is unavailable or the request fails. order sets a preference; it does not restrict fallback to GMI Cloud. See provider ordering.
The dropdown lists models served by GMI Cloud through Gateway with a corresponding direct-provider example. Provider availability depends on the model and your team's Provider Allowlist.
Using @ai-sdk/gmicloud
For direct access to GMI Cloud, install ai and @ai-sdk/gmicloud:
pnpm add ai @ai-sdk/gmicloudnpm install ai @ai-sdk/gmicloudyarn add ai @ai-sdk/gmicloudbun add ai @ai-sdk/gmicloudSet your GMI Cloud API credential in the GMI_CLOUD_APIKEY environment variable:
export GMI_CLOUD_APIKEY=your_api_key_hereAI Gateway does not expose every API in @ai-sdk/gmicloud. Use the direct provider for provider-specific APIs or custom connection settings.
Note
The following sections document the direct @ai-sdk/gmicloud provider,
including its model factories and settings. Gateway model and feature
availability can differ.
API keys can be obtained from the GMI Cloud console.
Provider Instance
You can import the default provider instance gmicloud from @ai-sdk/gmicloud:
import { gmicloud } from '@ai-sdk/gmicloud';For custom configuration, you can import createGmicloud and create a provider instance with your settings:
import { createGmicloud } from '@ai-sdk/gmicloud';
const gmicloud = createGmicloud({
apiKey: process.env.GMI_CLOUD_APIKEY ?? '',
});You can use the following optional settings to customize the GMI Cloud provider instance:
-
baseURL string
Use a different URL prefix for API calls. The default prefix is
https://api.gmi-serving.com/v1. -
apiKey string
API key that is being sent using the
Authorizationheader. It defaults to theGMI_CLOUD_APIKEYenvironment variable. -
headers Record<string,string>
Custom headers to include in the requests.
-
fetch FetchFunction
Custom fetch implementation.
Language Models
import { gmicloud } from '@ai-sdk/gmicloud';
import { generateText } from 'ai';
const { text } = await generateText({
model: gmicloud('deepseek-ai/DeepSeek-V4-Flash-0731'),
prompt: 'What is the capital of France?',
});GMI Cloud serves an evolving catalog of open-weight models, so model ids are typed as string. Embedding and image models are not supported.
Error diagnostics
GMI Cloud's edge reports a generic banner in error.message on rejections and nests the backend engine's diagnostic in error.details. This provider unwraps the nested diagnostic, so AI_APICallError.message carries the engine's reason (e.g. The request is invalid: Invalid max_tokens value, the valid range of max_tokens is [1, 393216].) instead of Backend request failed with status 400.