Tuesday, November 4, 2025
HomeArtificial IntelligenceThe best way to Use the DeepSeek API

The best way to Use the DeepSeek API

TL;DR

DeepSeek fashions, together with DeepSeek‑R1 and DeepSeek‑V3.1, are accessible immediately by the Clarifai platform. You will get began without having a separate DeepSeek API key or endpoint.

  • Experiment within the Playground: Join a Clarifai account and open the Playground. This allows you to check prompts interactively, modify parameters, and perceive the mannequin habits earlier than integration.
  • Combine by way of API: Combine fashions by way of Clarifai’s OpenAI-compatible endpoint by specifying the mannequin URL and authenticating along with your Private Entry Token (PAT).

https://api.clarifai.com/v2/ext/openai/v1

Authenticate along with your Private Entry Token (PAT) and specify the mannequin URL, comparable to DeepSeek‑R1 or DeepSeek‑V3.1.

Clarifai handles all internet hosting, scaling, and orchestration, letting you focus purely on constructing your software and utilizing the mannequin’s reasoning and chat capabilities.

DeepSeek in 90 Seconds—What and Why

DeepSeek encompasses a variety of huge language fashions (LLMs) designed with numerous architectural methods to optimize efficiency throughout varied duties. Whereas some fashions make use of a Combination-of-Specialists (MoE) strategy, others make the most of dense architectures to stability effectivity and functionality.

1. DeepSeek-R1

DeepSeek-R1 is a dense mannequin that integrates reinforcement studying (RL) with data distillation to reinforce reasoning capabilities. It employs an ordinary transformer structure augmented with Multi-Head Latent Consideration (MLA) to enhance context dealing with and scale back reminiscence overhead. This design allows the mannequin to realize excessive efficiency in duties requiring deep reasoning, comparable to arithmetic and logic.

2. DeepSeek-V3

DeepSeek-V3 adopts a hybrid strategy, combining each dense and MoE parts. The dense half handles common conversational duties, whereas the MoE element prompts specialised specialists for advanced reasoning duties. This structure permits the mannequin to effectively swap between common and specialised modes, optimizing efficiency throughout a broad spectrum of purposes.

3. Distilled Fashions

To supply extra accessible choices, DeepSeek affords distilled variations of its fashions, comparable to DeepSeek-R1-Distill-Qwen-7B. These fashions are smaller in measurement however retain a lot of the reasoning and coding capabilities of their bigger counterparts. As an example, DeepSeek-R1-Distill-Qwen-7B relies on the Qwen 2.5 structure and has been fine-tuned with reasoning knowledge generated by DeepSeek-R1, reaching robust efficiency in mathematical reasoning and common problem-solving duties.

The best way to Entry DeepSeek on Clarifai

DeepSeek fashions will be accessed on Clarifai in 3 ways: by the Clarifai Playground UI, by way of the OpenAI-compatible API, or utilizing the Clarifai SDK. Every technique offers a distinct degree of management and suppleness, permitting you to experiment, combine, and deploy fashions in accordance with your growth workflow.

Clarifai Playground

The Playground offers a quick, interactive surroundings to check prompts and discover mannequin habits. 

You possibly can choose any DeepSeek mannequin, together with DeepSeek‑R1, DeepSeek‑V3.1, or distilled variations obtainable on the neighborhood. You possibly can enter prompts, modify parameters comparable to temperature and streaming, and instantly see the mannequin responses. The Playground additionally means that you can evaluate a number of fashions facet by facet to check and consider their responses.

Throughout the Playground itself, you’ve the choice to view the API part, the place you possibly can entry code snippets in a number of languages, together with cURL, Java, JavaScript, Node.js, the OpenAI-compatible API, the Clarifai Python SDK, PHP, and extra. 

You possibly can choose the language you want, copy the snippet, and immediately combine it into your purposes. For extra particulars on testing fashions and utilizing the Playground, see the Clarifai Playground Quickstart

Attempt it: The Clarifai Playground is the quickest technique to check prompts. Navigate to the mannequin web page and click on “Check in Playground”.

Through the OpenAI‑Suitable API

Clarifai offers a drop-in alternative for the OpenAI API, permitting you to make use of the identical Python or TypeScript consumer libraries you’re aware of whereas pointing to Clarifai’s OpenAI-compatible endpoint. Upon getting your PAT set as an surroundings variable, you possibly can name any Clarifai-hosted DeepSeek mannequin by specifying the mannequin URL.

Python Instance

import os

from openai import OpenAI

 

consumer = OpenAI(

    base_url=“https://api.clarifai.com/v2/ext/openai/v1”,

    api_key=os.environ[“CLARIFAI_PAT”]

)

response = consumer.chat.completions.create(

    mannequin=“https://clarifai.com/deepseek-ai/deepseek-chat/fashions/DeepSeek-R1”,

    messages=[

        {“role”: “system”, “content”: “You are a helpful assistant.”},

        {“role”: “user”, “content”: “Tell me a three sentence bedtime story about a unicorn.”}

    ],

    max_completion_tokens=100,

    temperature=0.7

)

print(response.selections[0].message.content material)

TypeScript Instance

import OpenAI from “openai”;

const consumer = new OpenAI({

  baseURL: “https://api.clarifai.com/v2/ext/openai/v1”,

  apiKey: course of.env.CLARIFAI_PAT,

});

 

const response = await consumer.chat.completions.create({

  mannequin: “https://clarifai.com/deepseek-ai/deepseek-chat/fashions/DeepSeek-R1”,

  messages: [

    { role: “system”, content: “You are a helpful assistant.” },

    { role: “user”, content: “Who are you?” }

  ],

});

console.log(response.selections?.[0]?.message.content material);

Clarifai Python SDK

Clarifai’s Python SDK simplifies authentication and mannequin calls, permitting you to work together with DeepSeek fashions utilizing concise Python code. After setting your PAT, you possibly can initialize a mannequin consumer and make predictions with only a few strains.

import os

from clarifai.consumer import Mannequin

mannequin = Mannequin(

    url=“https://clarifai.com/deepseek-ai/deepseek-chat/fashions/DeepSeek-V3_1”,

    pat=os.environ[“CLARIFAI_PAT”]

)

response = mannequin.predict(

    immediate=“What’s the way forward for AI?”,

    max_tokens=512,

    temperature=0.7,

    top_p=0.95,

    pondering=“False”

)

print(response)

Vercel AI SDK

For contemporary net purposes, the Vercel AI SDK offers a TypeScript toolkit to work together with Clarifai fashions. It helps the OpenAI-compatible supplier, enabling seamless integration.

import { createOpenAICompatible } from “@ai-sdk/openai-compatible”;

import { generateText } from “ai”;

const clarifai = createOpenAICompatible({

  baseURL: “https://api.clarifai.com/v2/ext/openai/v1”,

  apiKey: course of.env.CLARIFAI_PAT,

});

const mannequin = clarifai(“https://clarifai.com/deepseek-ai/deepseek-chat/fashions/DeepSeek-R1”);

const { textual content } = await generateText({

  mannequin,

  messages: [

    { role: “system”, content: “You are a helpful assistant.” },

    { role: “user”, content: “What is photosynthesis?” }

  ],

});

console.log(textual content);

This SDK additionally helps streaming responses, software calling, and different superior options.Along with the above, DeepSeek fashions can be accessed by way of cURL, PHP, Java, and different languages. For a whole record of integration strategies, supported suppliers, and superior utilization examples, seek advice from the documentation.

Superior Inference Patterns

DeepSeek fashions on Clarifai assist superior inference options that make them appropriate for production-grade workloads. You possibly can allow streaming for low-latency responses, and software calling to let the mannequin work together dynamically with exterior programs or APIs. These capabilities work seamlessly by Clarifai’s OpenAI-compatible API.

Streaming Responses

Streaming returns mannequin output token by token, bettering responsiveness in real-time purposes like chat interfaces or dashboards. The instance under reveals how one can stream responses from a DeepSeek mannequin hosted on Clarifai.

import os

from openai import OpenAI

# Initialize the OpenAI-compatible consumer for Clarifai

consumer = OpenAI(

    base_url=“https://api.clarifai.com/v2/ext/openai/v1”,

    api_key=os.environ[“CLARIFAI_PAT”]

)

# Create a chat completion request with streaming enabled

response = consumer.chat.completions.create(

    mannequin=“https://clarifai.com/deepseek-ai/deepseek-chat/fashions/DeepSeek-V3_1”,

    messages=[

        {“role”: “system”, “content”: “You are a helpful assistant.”},

        {“role”: “user”, “content”: “Explain how transformers work in simple terms.”}

    ],

    max_completion_tokens=150,

    temperature=0.7,

    stream=True

)

print(“Assistant’s Response:”)

for chunk in response:

    if chunk.selections and chunk.selections[0].delta and chunk.selections[0].delta.content material is not None:

        print(chunk.selections[0].delta.content material, finish=“”)

print(“n”)

Streaming helps you render partial responses as they arrive as a substitute of ready for all the output, decreasing perceived latency.

Device Calling

Device calling allows a mannequin to invoke exterior features throughout inference, which is very helpful for constructing AI brokers that may work together with APIs, fetch reside knowledge, or carry out dynamic reasoning. DeepSeek-V3.1 helps software calling, permitting your brokers to make context-aware choices. Under is an instance of defining and utilizing a software with a DeepSeek mannequin.

import os

from openai import OpenAI

# Initialize the OpenAI-compatible consumer for Clarifai

consumer = OpenAI(

    base_url=“https://api.clarifai.com/v2/ext/openai/v1”,

    api_key=os.environ[“CLARIFAI_PAT”]

)

# Outline a easy perform the mannequin can name

instruments = [

    {

        “type”: “function”,

        “function”: {

            “name”: “get_weather”,

            “description”: “Returns the current temperature for a given location.”,

            “parameters”: {

                “type”: “object”,

                “properties”: {

                    “location”: {

                        “type”: “string”,

                        “description”: “City and country, for example ‘New York, USA'”

                    }

                },

                “required”: [“location”],

                “additionalProperties”: False

            }

        }

    }

]

# Create a chat completion request with tool-calling enabled

response = consumer.chat.completions.create(

    mannequin=“https://clarifai.com/deepseek-ai/deepseek-chat/fashions/DeepSeek-V3_1”,

    messages=[

        {“role”: “user”, “content”: “What is the weather like in New York today?”}

    ],

    instruments=instruments,

    tool_choice=‘auto’

)

# Print the software name proposed by the mannequin

tool_calls = response.selections[0].message.tool_calls

print(“Device calls:”, tool_calls)

For extra superior inference patterns, together with multi-turn reasoning, structured output era, and prolonged examples of streaming and gear calling, seek advice from the documentation

Which DeepSeek Mannequin Ought to I Decide?

Clarifai hosts a number of DeepSeek variants. Choosing the proper one depends upon your job:

  • DeepSeek‑R1use for reasoning and complicated code. It excels at mathematical proofs, algorithm design, debugging and logical inference. Anticipate slower responses as a consequence of prolonged “pondering mode,” and better token utilization.
  • DeepSeek‑V3.1use for common chat and light-weight coding. V3.1 is a hybrid: it might swap between non‑pondering mode (quicker, cheaper) and pondering mode (deeper reasoning) inside a single mannequin. Very best for summarization, Q&A and on a regular basis assistant duties.
  • Distilled fashions (R1‑Distill‑Qwen‑7B, and so forth.) – these are smaller variations of the bottom fashions, providing decrease latency and price with barely decreased reasoning depth. Use them when pace issues greater than maximal efficiency.

On the time of writing, DeepSeek‑OCR has simply been introduced and isn’t but obtainable on Clarifai. Regulate Clarifai’s mannequin catalog for updates.

Steadily Requested Questions (FAQs)

Q1: Do I want a DeepSeek API key?
No. When utilizing Clarifai, you solely want a Clarifai Private Entry Token. Don’t use or expose the DeepSeek API key except you’re calling DeepSeek immediately (which this information doesn’t cowl).

Q2: How do I swap between fashions in code?
Change the mannequin worth to the Clarifai mannequin ID, comparable to openai/deepseek-ai/deepseek-chat/fashions/DeepSeek-R1 for R1 or openai/deepseek-ai/deepseek-chat/fashions/DeepSeek-V3.1 for V3.1.

Q3: What parameters can I tweak?
You possibly can modify temperature, top_p and max_tokens to regulate randomness, sampling breadth and output size. For streaming responses, set stream=True. Device calling requires defining a software schema.

This autumn: Are there price limits?
Clarifai enforces tender price limits per PAT. Implement exponential backoff and keep away from retrying 4XX errors. For top throughput, contact Clarifai to extend quotas.

Q5: Is my knowledge safe?
Clarifai processes requests in safe environments and complies with main knowledge‑safety requirements. Retailer your PAT securely and keep away from together with delicate knowledge in prompts except needed.

Q6: Can I nice‑tune DeepSeek fashions?
DeepSeek fashions are MIT‑licensed. Clarifai plans to supply personal internet hosting and nice‑tuning for enterprise clients within the close to future. Till then, you possibly can obtain and nice‑tune the open‑supply fashions by yourself infrastructure.

Conclusion

You now have a quick, customary technique to combine DeepSeek fashions, together with R1, V3.1, and distilled variants, into your purposes. Clarifai handles all infrastructure, scaling, and orchestration. No separate DeepSeek key or advanced setup is required. Attempt the fashions at present by the Clarifai Playground or API and combine them into your purposes.


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments