To invoke models using the MaaS by Token method, follow these steps:
Obtain API Key: Log in to your user console and create a new API Key
Set Endpoint: Replace the SDK endpoint with chat.d.run
Invoke Model: Use the official model name along with the new API Key for invocation
Example Code (Python):
importopenaiopenai.api_key="your-api-key"# Replace with your API Keyopenai.api_base="https://chat.d.run"response=openai.Completion.create(model="public/deepseek-r1",prompt="What is your name?")print(response.choices[0].text)
To invoke models using the Model Service method, follow these steps:
Obtain API Key: Log in to your user console and create a new API Key
Set Endpoint: Replace the SDK endpoint with <region>.d.run
Invoke Model: Use the official model name along with the new API Key for invocation
Example Code (Python):
importopenaiopenai.api_key="your-api-key"# Replace with your API Keyopenai.api_base="<region>.d.run"response=openai.Completion.create(model="u-1100a15812cc/qwen2",prompt="What is your name?")print(response.choices[0].text)