Configure authentication
Applications that need explicit credential management or multiple provider configurations.
AI Tools · Function
createDeepSeek creates a configurable DeepSeek provider for the AI SDK. Configure credentials, endpoint, headers, or request handling, then select a DeepSeek model from the returned provider.
createDeepSeek constructs a DeepSeek provider instance from optional settings. The resulting provider can be called with a model identifier, such as deepseek-chat, and passed to AI SDK operations.
createDeepSeek(options?: { baseURL?: string; apiKey?: string; headers?: Record<string, string>; fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response> })| Name | Type | Description |
|---|---|---|
baseURL | string | Optional URL prefix used for API calls; the documented default is https://api.deepseek.com. |
apiKey | string | API key sent using the Authorization header; defaults to the DEEPSEEK_API_KEY environment variable. |
headers | Record<string, string> | Additional headers included in requests. |
fetch | (input: RequestInfo, init?: RequestInit) => Promise<Response> | Custom function for performing requests. |
A configured DeepSeek provider instance that can be used to select DeepSeek models.
import { createDeepSeek } from '@ai-sdk/deepseek';
import { generateText } from 'ai';
const deepSeek = createDeepSeek({
apiKey: process.env.DEEPSEEK_API_KEY ?? '',
});
const { text } = await generateText({
model: deepSeek('deepseek-chat'),
prompt: 'Explain dependency injection briefly.',
});
console.log(text);Creates a configured DeepSeek provider and uses it to select a model for text generation.
Applications that need explicit credential management or multiple provider configurations.
Deployments using a compatible proxy, gateway, or alternate API endpoint.
Systems that require custom request headers or transport behavior.
createDeepSeek creates a customized DeepSeek provider instance from configuration such as an API key, base URL, headers, or a fetch implementation. The returned provider is then used to select DeepSeek models.
Follow-up: How would you change the endpoint? Set baseURL in the provider configuration; the documentation describes it as the URL prefix used for API calls.
The apiKey setting supplies the key sent in the Authorization header. If it is not provided, the provider uses the DEEPSEEK_API_KEY environment variable.
Follow-up: How could requests be modified without changing model calls? Provide custom headers or a custom fetch function in the provider settings.
A provider instance is callable with a model identifier, for example deepSeek('deepseek-chat'), and the resulting model can be supplied to AI SDK functions such as generateText. This keeps provider setup separate from model execution.
Follow-up: What is the benefit of a provider instance? It centralizes endpoint and request configuration while allowing multiple model selections through the same configured provider.
@ai-sdk/deepseekdeepSeekdeepseek-chatdeepseek-reasonergenerateText