Blog
API Guides2 phút đọc

DeepSeek V3 API: Complete Setup Guide

DeepSeek V3 API Setup

DeepSeek V3 offers GPT-4 level performance at 90% lower cost. Here's how to get started.

Why DeepSeek V3?

| Feature | DeepSeek V3 | GPT-4o | |---|---|---| | Input Price | $0.27/1M | $2.50/1M | | Output Price | $1.10/1M | $10.00/1M | | Context | 128K | 128K | | Code | ✅ Strong | ✅ Strong | | Math | ✅ Strong | ✅ Strong |

Python Example

import openai

client = openai.OpenAI(
    api_key="your-api-key",
    base_url="https://api.apiyihe.org/v1"
)

response = client.chat.completions.create(
    model="deepseek-v3",
    messages=[
        {"role": "system", "content": "You are a helpful coding assistant."},
        {"role": "user", "content": "Write a Python function to sort a list of dictionaries by a key."}
    ],
    temperature=0.7,
    max_tokens=1000
)

print(response.choices[0].message.content)

JavaScript Example

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "your-api-key",
  baseURL: "https://api.apiyihe.org/v1",
});

const response = await client.chat.completions.create({
  model: "deepseek-v3",
  messages: [
    { role: "user", content: "Explain quantum computing in simple terms." }
  ],
});

console.log(response.choices[0].message.content);

cURL Example

curl https://api.apiyihe.org/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{
    "model": "deepseek-v3",
    "messages": [{"role": "user", "content": "Hello, DeepSeek!"}]
  }'

Streaming Support

stream = client.chat.completions.create(
    model="deepseek-v3",
    messages=[{"role": "user", "content": "Write a poem about AI"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

DeepSeek V3 supports all standard OpenAI-compatible parameters including streaming, temperature, top_p, and function calling.

Get Your API Key Now

Start building with 50+ AI models through one unified gateway.

Tạo Tài Khoản
Nhận Khóa API