#deepseek-r1 API via OpenRouter with DeepSeek provider does not work

4 messages · Page 1 of 1 (latest)

placid kindle
#

I am not able to get my Openrouter API Python script to work with the deepseek.com provider for the 'deepseek-r1' model.
It works fine with other providers, but not with the provider which is the Deepseek company itself.

I am just using the python script https://openrouter.ai/deepseek/deepseek-r1/api with the Python's 'requests':

import requests
import json

response = requests.post(
  url="https://openrouter.ai/api/v1/chat/completions",
  headers={
    "Authorization": "Bearer <OPENROUTER_API_KEY>",
    "Content-Type": "application/json"
        
  },
  data=json.dumps({
    "model": "deepseek/deepseek-r1",
    "messages": [
      {
        "role": "user",
        "content": "What is the meaning of life?"
      }
    ],
        "provider": {
        "require_parameters": True,
        "order": [
            "DeepSeek"
            #"Fireworks",
            #"Friendli"
            #"Parasail",
            #"Kluster",
            #"Nebius",
            
        ],
        "allow_fallbacks": False
        
    },
    
    
  })
)

Sample code and API for DeepSeek: R1 - DeepSeek R1 is here: Performance on par with OpenAI o1, but open-sourced and with fully open reasoning tokens. It's 671B parameters in size, with 37B active in an inference pass.

Fully open-source model & technical report.

MIT licensed: Distil...

placid kindle
#

It was no specific error, was just timing out or picking another provider.

#

Hmm...It started working now.