Skip to content

How can ellmer integrate DeepSeek provided by other manufacturers? #296

Description

@trafficfan

DeepseekR1 is open-source and available from many manufacturers, but the price of the tokens varies. I found a cheaper option, but there were problems with the integration.
The provider‘s web here
百度云文档
here's the python code

from openai import OpenAI

client = OpenAI(
   api_key="bce-v3/ALTAK-KZke********/f1d6ee*************",  # bearer token
   base_url="https://qianfan.baidubce.com/v2"
)

completion = client.chat.completions.create(
    model="deepseek-r1",   
    messages=[{'role': 'system', 'content': 'You are a helpful assistant.'},
              {'role': 'user', 'content': '你是谁?'}]
)

print(completion.choices[0].message)

I've tried ellmer, maybe it should be like

library(ellmer)
chat <- chat_openai(
  system_prompt = NULL,
  turns = NULL,
  base_url = "https://qianfan.baidubce.com/v2/chat/completions",
  api_key = "bce-v3/ALTAK-KZke********/f1d6ee*************",
  model = "deepseek-r1",
  seed = NULL,
  api_args = list(),
  echo = c("none", "text", "all")
)
chat$chat("
  What is the difference between a tibble and a data frame?
  Answer with a bulleted list
")

chat$chat("Tell me three funny jokes about statistcians")

however it returns

Error in `httr2::req_perform_connection()`:
! HTTP 404 Not Found.
Run `rlang::last_trace()` to see where the error occurred.

I want to know if it's my code that's wrong or if Ellmer doesn't support it temporarily? I think I used the correct API key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions