1 line
10 KiB
JSON
1 line
10 KiB
JSON
{"repo": "berkay2002/clairvoyant", "files": {"docs/vercel-ai-sdk/deepseek.md": {"dd212931035fc5bbaf2b0279b48c08ff4ac4ea80": {"t": 1785746499.4554102, "n": 4825, "h": "8b9dcb5df7a43538", "c": "\n# DeepSeek Provider\n\nThe [DeepSeek](https://www.deepseek.com) provider offers access to powerful language models through the DeepSeek API, including their [DeepSeek-V3 model](https://github.com/deepseek-ai/DeepSeek-V3).\n\nAPI keys can be obtained from the [DeepSeek Platform](https://platform.deepseek.com/api_keys).\n\n## Setup\n\nThe DeepSeek provider is available via the `@ai-sdk/deepseek` module. You can install it with:\n\n<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>\n <Tab>\n <Snippet text=\"pnpm add @ai-sdk/deepseek\" dark />\n </Tab>\n <Tab>\n <Snippet text=\"npm install @ai-sdk/deepseek\" dark />\n </Tab>\n <Tab>\n <Snippet text=\"yarn add @ai-sdk/deepseek\" dark />\n </Tab>\n\n <Tab>\n <Snippet text=\"bun add @ai-sdk/deepseek\" dark />\n </Tab>\n</Tabs>\n\n## Provider Instance\n\nYou can import the default provider instance `deepseek` from `@ai-sdk/deepseek`:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\n```\n\nFor custom configuration, you can import `createDeepSeek` and create a provider instance with your settings:\n\n```ts\nimport { createDeepSeek } from '@ai-sdk/deepseek';\n\nconst deepseek = createDeepSeek({\n apiKey: process.env.DEEPSEEK_API_KEY ?? '',\n});\n```\n\nYou can use the following optional settings to customize the DeepSeek provider instance:\n\n- **baseURL** _string_\n\n Use a different URL prefix for API calls.\n The default prefix is `https://api.deepseek.com/v1`.\n\n- **apiKey** _string_\n\n API key that is being sent using the `Authorization` header. It defaults to\n the `DEEPSEEK_API_KEY` environment variable.\n\n- **headers** _Record<string,string>_\n\n Custom headers to include in the requests.\n\n- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_\n\n Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.\n\n## Language Models\n\nYou can create language models using a provider instance:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\nimport { generateText } from 'ai';\n\nconst { text } = await generateText({\n model: deepseek('deepseek-chat'),\n prompt: 'Write a vegetarian lasagna recipe for 4 people.',\n});\n```\n\nYou can also use the `.chat()` or `.languageModel()` factory methods:\n\n```ts\nconst model = deepseek.chat('deepseek-chat');\n// or\nconst model = deepseek.languageModel('deepseek-chat');\n```\n\nDeepSeek language models can be used in the `streamText` function\n(see [AI SDK Core](/docs/ai-sdk-core)).\n\n### Reasoning\n\nDeepSeek has reasoning support for the `deepseek-reasoner` model. The reasoning is exposed through streaming:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\nimport { streamText } from 'ai';\n\nconst result = streamText({\n model: deepseek('deepseek-reasoner'),\n prompt: 'How many \"r\"s are in the word \"strawberry\"?',\n});\n\nfor await (const part of result.fullStream) {\n if (part.type === 'reasoning') {\n // This is the reasoning text\n console.log('Reasoning:', part.text);\n } else if (part.type === 'text') {\n // This is the final answer\n console.log('Answer:', part.text);\n }\n}\n```\n\nSee [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details\non how to integrate reasoning into your chatbot.\n\n### Cache Token Usage\n\nDeepSeek provides context caching on disk technology that can significantly reduce token costs for repeated content. You can access the cache hit/miss metrics through the `providerMetadata` property in the response:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\nimport { generateText } from 'ai';\n\nconst result = await generateText({\n model: deepseek('deepseek-chat'),\n prompt: 'Your prompt here',\n});\n\nconsole.log(result.providerMetadata);\n// Example output: { deepseek: { promptCacheHitTokens: 1856, promptCacheMissTokens: 5 } }\n```\n\nThe metrics include:\n\n- `promptCacheHitTokens`: Number of input tokens that were cached\n- `promptCacheMissTokens`: Number of input tokens that were not cached\n\n<Note>\n For more details about DeepSeek's caching system, see the [DeepSeek caching\n documentation](https://api-docs.deepseek.com/guides/kv_cache#checking-cache-hit-status).\n</Note>\n\n## Model Capabilities\n\n| Model | Text Generation | Object Generation | Image Input | Tool Usage | Tool Streaming |\n| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |\n| `deepseek-chat` | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |\n| `deepseek-reasoner` | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |\n\n<Note>\n Please see the [DeepSeek docs](https://api-docs.deepseek.com) for a full list\n of available models. You can also pass any available provider model ID as a\n string if needed.\n</Note>\n"}, "2c304116ac262159f838e4cefa9968c6db6176f4": {"t": 1785764985.4413552, "n": 4825, "h": "8b9dcb5df7a43538", "c": "\n# DeepSeek Provider\n\nThe [DeepSeek](https://www.deepseek.com) provider offers access to powerful language models through the DeepSeek API, including their [DeepSeek-V3 model](https://github.com/deepseek-ai/DeepSeek-V3).\n\nAPI keys can be obtained from the [DeepSeek Platform](https://platform.deepseek.com/api_keys).\n\n## Setup\n\nThe DeepSeek provider is available via the `@ai-sdk/deepseek` module. You can install it with:\n\n<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>\n <Tab>\n <Snippet text=\"pnpm add @ai-sdk/deepseek\" dark />\n </Tab>\n <Tab>\n <Snippet text=\"npm install @ai-sdk/deepseek\" dark />\n </Tab>\n <Tab>\n <Snippet text=\"yarn add @ai-sdk/deepseek\" dark />\n </Tab>\n\n <Tab>\n <Snippet text=\"bun add @ai-sdk/deepseek\" dark />\n </Tab>\n</Tabs>\n\n## Provider Instance\n\nYou can import the default provider instance `deepseek` from `@ai-sdk/deepseek`:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\n```\n\nFor custom configuration, you can import `createDeepSeek` and create a provider instance with your settings:\n\n```ts\nimport { createDeepSeek } from '@ai-sdk/deepseek';\n\nconst deepseek = createDeepSeek({\n apiKey: process.env.DEEPSEEK_API_KEY ?? '',\n});\n```\n\nYou can use the following optional settings to customize the DeepSeek provider instance:\n\n- **baseURL** _string_\n\n Use a different URL prefix for API calls.\n The default prefix is `https://api.deepseek.com/v1`.\n\n- **apiKey** _string_\n\n API key that is being sent using the `Authorization` header. It defaults to\n the `DEEPSEEK_API_KEY` environment variable.\n\n- **headers** _Record<string,string>_\n\n Custom headers to include in the requests.\n\n- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_\n\n Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.\n\n## Language Models\n\nYou can create language models using a provider instance:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\nimport { generateText } from 'ai';\n\nconst { text } = await generateText({\n model: deepseek('deepseek-chat'),\n prompt: 'Write a vegetarian lasagna recipe for 4 people.',\n});\n```\n\nYou can also use the `.chat()` or `.languageModel()` factory methods:\n\n```ts\nconst model = deepseek.chat('deepseek-chat');\n// or\nconst model = deepseek.languageModel('deepseek-chat');\n```\n\nDeepSeek language models can be used in the `streamText` function\n(see [AI SDK Core](/docs/ai-sdk-core)).\n\n### Reasoning\n\nDeepSeek has reasoning support for the `deepseek-reasoner` model. The reasoning is exposed through streaming:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\nimport { streamText } from 'ai';\n\nconst result = streamText({\n model: deepseek('deepseek-reasoner'),\n prompt: 'How many \"r\"s are in the word \"strawberry\"?',\n});\n\nfor await (const part of result.fullStream) {\n if (part.type === 'reasoning') {\n // This is the reasoning text\n console.log('Reasoning:', part.text);\n } else if (part.type === 'text') {\n // This is the final answer\n console.log('Answer:', part.text);\n }\n}\n```\n\nSee [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details\non how to integrate reasoning into your chatbot.\n\n### Cache Token Usage\n\nDeepSeek provides context caching on disk technology that can significantly reduce token costs for repeated content. You can access the cache hit/miss metrics through the `providerMetadata` property in the response:\n\n```ts\nimport { deepseek } from '@ai-sdk/deepseek';\nimport { generateText } from 'ai';\n\nconst result = await generateText({\n model: deepseek('deepseek-chat'),\n prompt: 'Your prompt here',\n});\n\nconsole.log(result.providerMetadata);\n// Example output: { deepseek: { promptCacheHitTokens: 1856, promptCacheMissTokens: 5 } }\n```\n\nThe metrics include:\n\n- `promptCacheHitTokens`: Number of input tokens that were cached\n- `promptCacheMissTokens`: Number of input tokens that were not cached\n\n<Note>\n For more details about DeepSeek's caching system, see the [DeepSeek caching\n documentation](https://api-docs.deepseek.com/guides/kv_cache#checking-cache-hit-status).\n</Note>\n\n## Model Capabilities\n\n| Model | Text Generation | Object Generation | Image Input | Tool Usage | Tool Streaming |\n| ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |\n| `deepseek-chat` | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |\n| `deepseek-reasoner` | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |\n\n<Note>\n Please see the [DeepSeek docs](https://api-docs.deepseek.com) for a full list\n of available models. You can also pass any available provider model ID as a\n string if needed.\n</Note>\n"}}}} |