vercel/ai · warning

TOGETHER_AI_API_KEY is deprecated and will be removed in a f

Error message

TOGETHER_AI_API_KEY is deprecated and will be removed in a future release. Please use TOGETHER_API_KEY instead.

What it means

The TogetherAI provider loads its API key from an environment variable; TOGETHER_AI_API_KEY is the deprecated name. When only the deprecated variable is set (and TOGETHER_API_KEY is not), the key still works but this deprecation warning is printed, because the variable will be removed in a future release.

Source

Thrown at packages/togetherai/src/togetherai-provider.ts:110

  reranking(modelId: TogetherAIRerankingModelId): RerankingModelV4;

  /**
   * Creates a model for reranking.
   */
  rerankingModel(modelId: TogetherAIRerankingModelId): RerankingModelV4;
}

function loadDeprecatedApiKey(): string | undefined {
  if (typeof process === 'undefined') {
    return undefined;
  }
  // If the new env var is set, let loadApiKey handle it
  if (typeof process.env.TOGETHER_API_KEY === 'string') {
    return undefined;
  }
  const key = process.env.TOGETHER_AI_API_KEY;
  if (typeof key === 'string') {
    console.warn(
      'TOGETHER_AI_API_KEY is deprecated and will be removed in a future release. Please use TOGETHER_API_KEY instead.',
    );
  }
  return key;
}

export function getModelStructuredOutputSupport(
  modelId: TogetherAIChatModelId,
): boolean {
  return modelId === 'deepseek-ai/DeepSeek-V4-Flash-0731';
}

export function createTogetherAI(
  options: TogetherAIProviderSettings = {},
): TogetherAIProvider {
  const baseURL = withoutTrailingSlash(
    options.baseURL ?? 'https://api.together.xyz/v1/',
  );

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Rename the environment variable from TOGETHER_AI_API_KEY to TOGETHER_API_KEY in your .env / hosting secret settings.
  2. Alternatively pass the key explicitly via createTogetherAI({ apiKey: '...' }).
  3. Update CI/CD secret names and any IaC templates referencing the old variable.
  4. If you set both, keep only TOGETHER_API_KEY to keep behavior predictable.

Example fix

// before (.env)
TOGETHER_AI_API_KEY=sk-...
// after (.env)
TOGETHER_API_KEY=sk-...
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.TOGETHER_AI_API_KEY && !process.env.TOGETHER_API_KEY) {
  console.warn('Rename TOGETHER_AI_API_KEY to TOGETHER_API_KEY before the next release.');
}

Prevention

When it happens

Trigger: Creating the TogetherAI provider (createTogetherAI or the default export) with only process.env.TOGETHER_AI_API_KEY set and no explicit apiKey argument and no TOGETHER_API_KEY.

Common situations: Older .env files or CI secrets configured before the env var rename; deployment platforms where legacy secret names persist after upgrading @ai-sdk/togetherai.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/b92be5062a5289fc. Report an issue: GitHub.