thezakuloGet the newsletter
← All setup guides

Setup guide · 4 steps · about 15 minutes

How to start using DeepSeek: DeepSeek V4.1 Flash

DeepSeek V4.1 Flash (deepseek/deepseek-v4.1-flash) is a sparse mixture-of-experts model with a 1,048,576-token context that accepts text and images and returns text, suited for coding, terminal, and computer-use agents, long-horizon tasks, and long-context analysis.

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

  1. 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>
  2. 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?"
    }'
  3. 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)
  4. 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

  1. 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>
  2. 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.

Try these first

Get every issue by email

One email a week with the written issue. Free, one-click unsubscribe

Subscribe