apideepseek
apideepseek is an async Python client for the private DeepSeek API. It supports token or email/password authentication, streaming responses, multi-turn conversations, image uploads, generic file uploads, model modes, and account registration.
Russian documentation: docs/ru/README.md
Installation
pip install apideepseek
Building from source requires a C++17 compiler with AVX2 support and pybind11 for the PoW extension. See docs/en/pow.md.
Quick Start
import asyncio
from apideepseek import DeepSeekClient
async def main():
async with DeepSeekClient(token="YOUR_TOKEN") as client:
result = await client.ask("Hello!")
print(result.text)
asyncio.run(main())
Email/password login also works:
async with DeepSeekClient(email="myname@example.com", password="password123") as client:
result = await client.ask("Hello!")
print(result.text)
Model Modes
| Mode | Use When | Code |
|---|---|---|
| Fast/default | Normal text chat and most file questions | ModelType.DEFAULT |
| Expert | Harder reasoning or expert answers | ModelType.EXPERT |
| Vision/recognition | Questions about images | ModelType.VISION |
from apideepseek import DeepSeekClient, ModelType
async with DeepSeekClient(token="...", model=ModelType.DEFAULT) as client:
fast = await client.ask("Short answer: what is asyncio?")
expert = await client.ask("Analyze this deeply", model=ModelType.EXPERT)
Attach Files to a Prompt
Use file= for one file and files= for several files. Paths are uploaded automatically before the prompt is sent.
from pathlib import Path
from apideepseek import DeepSeekClient
async with DeepSeekClient(token="...") as client:
result = await client.ask(
"Summarize this file",
file=Path("notes.txt"),
)
print(result.text)
You can attach source code the same way:
result = await client.ask(
"Review this function and explain what it returns",
file=Path("sample_code.py"),
)
Attach several files:
result = await client.ask(
"Compare the JSON config with the CSV data",
files=[Path("config.json"), Path("data.csv")],
)
Upload once and reuse the file object:
uploaded = await client.upload_file(Path("report.pdf"))
first = await client.ask("Summarize the report", file=uploaded)
second = await client.ask("List the key risks", file=uploaded)
Raw bytes work too, but you must provide a filename so DeepSeek can detect the format:
data = Path("contract.docx").read_bytes()
uploaded = await client.upload_file(data, filename="contract.docx")
result = await client.ask("Extract the main obligations", file=uploaded)
Common formats are passed through the same upload endpoint: TXT, Python/source code, JSON, CSV, PDF, DOCX, and other formats DeepSeek accepts. If DeepSeek rejects a file as empty or unsupported, EmptyUploadedFileError or DeepSeekError is raised.
Attach Images
Images can be attached through image= or through the generic file= parameter. Use image=/upload_image() when you want local PNG/JPEG validation and image dimensions.
from pathlib import Path
from apideepseek import DeepSeekClient, ModelType
async with DeepSeekClient(token="...") as client:
result = await client.ask(
"What is shown in this image?",
image=Path("photo.jpg"),
model=ModelType.VISION,
)
print(result.text)
Reuse an uploaded image:
img = await client.upload_image(Path("photo.jpg"))
result = await client.ask("Describe the image", image=img, model=ModelType.VISION)
Create a New Conversation
Use client.new_conversation() for a multi-turn chat. It remembers the last message_id and sends it as parent_message_id on the next turn.
chat = client.new_conversation()
await chat.ask("Remember the attached file", file=Path("notes.txt"))
reply = await chat.ask("What did the file say?")
print(reply.text)
Streaming
async for chunk in client.ask_stream("Tell me about Python"):
print(chunk, end="", flush=True)
Streaming works with files too:
async for chunk in client.ask_stream("Summarize this file", file=Path("notes.txt")):
print(chunk, end="", flush=True)
Result Object
result = await client.ask("Hello")
print(result.text)
print(result.session_id)
print(result.message_id)
Documentation
Metadata
Release files for apideepseek 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apideepseek-0.1.2.tar.gz | 61.5 kB | Without provenance | Details for apideepseek-0.1.2.tar.gz |
Release files / apideepseek-0.1.2.tar.gz
| Download URL | apideepseek-0.1.2.tar.gz |
|---|---|
| Size | 61.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba8af6b93c6d68fd2f2a7e2e29269206dd3766177d04e6900e2aae52057b258a
|
|
BLAKE2b-256 checksum How to use checksums |
86a14a5f50e0155624071a5f0c01396de31d878dea15a18d61e00232746209e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for apideepseek 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.