Built from the official docs: openrouter.ai · DeepSeek V4.1 Flash - API Pricing & Benchmarks · Your First API Call | DeepSeek API Docs · checked 27 November 2026
Through OpenRouter
Get an API key
Create an OpenRouter account and an API key, then set it as an environment variable in your terminal so the examples below can read it.
export OPENROUTER_API_KEY=<your-openrouter-key>Call the model with curl
Send an HTTP request to the OpenRouter responses endpoint with the model slug deepseek/deepseek-v4.1-flash.
curl https://openrouter.ai/api/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENROUTER_API_KEY" \ -d '{ "model": "deepseek/deepseek-v4.1-flash", "input": "What is the meaning of life?" }'Or use the OpenAI SDK pointed at OpenRouter
OpenRouter is OpenAI-compatible, so you can use the OpenAI SDK by setting the base URL to OpenRouter and passing your OpenRouter key.
from openai import OpenAI client = OpenAI( base_url="https://openrouter.ai/api/v1", api_key="<your-openrouter-key>", ) response = client.responses.create( model="deepseek/deepseek-v4.1-flash", input="What is the meaning of life?" ) print(response.output_text)Or use the OpenRouter Python SDK
Install the OpenRouter SDK with pip, then send a request with the model slug deepseek/deepseek-v4.1-flash.
pip install openrouter
Direct from DeepSeek
Get an API key
Apply for a DeepSeek API key from the DeepSeek platform, then set it as the DEEPSEEK_API_KEY environment variable in your terminal.
export DEEPSEEK_API_KEY=<your-deepseek-key>Call the chat API
The DeepSeek API uses an OpenAI-compatible format at base URL https://api.deepseek.com. Use deepseek-flash as the model name, which is served by DeepSeek-V4.1-Flash-1017.
curl https://api.deepseek.com/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \ -d '{ "model": "deepseek-flash", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "thinking": {"type": "enabled"}, "reasoning_effort": "high", "stream": false }'
Check it worked
You sent a request and got back a text completion in the response with no authentication error; through OpenRouter the response has an output_text field, and directly from DeepSeek it returns a chat completion.