Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
# DeepSeek provider: one or more bearer tokens, comma-separated
# TOKENS ==========================
# Open Developer -> Network settings; make sure logged in;
# - Deepseek: find a '/chat/completion' URL call and get the Authorization: Bearer XXXXXXXXXX)
# - Qwen: find a 'chats/' URL call and get the cookie (extract token=eyJhb... or paste the whole cookie string)
# DeepSeek/Qwen tokens (multiple = comma-separated)
DEEPSEEK_TOKENS=

# Qwen provider: one or more bearer tokens, comma-separated
QWEN_TOKENS=

# address the API server binds to

# CONNECTION ======================
# address the API server binds (alt HOST, PORT, PROXY, API_KEY)
DANYAPI_HOST=0.0.0.0
# port the API server listens on
DANYAPI_PORT=8000
# (optional) outgoing proxy for upstream communication
# (e.g. socks5://127.0.0.1:1080 or http://127.0.0.1:8080, docker: socks5://host.docker.internal:1080)
DANYAPI_PROXY=
# (optional) if enforcing USER Bearer token on user-api calls
DANYAPI_API_KEY=


# SETTINGS ========================
# upstream request timeout in seconds
DANYAPI_TIMEOUT=60
# human-like delay before each upstream request (seconds)
DANYAPI_HUMAN_DELAY_MIN=0.5
DANYAPI_HUMAN_DELAY_MAX=3.0
# seconds to wait for a free account before returning 429 (empty = wait forever)
DANYAPI_ACQUIRE_TIMEOUT=
# max server-side chats cached per provider (LRU) for stateless session reuse
DANYAPI_ACQUIRE_TIMEOUT=600

# SESSION: session_id -> maps to arbitrary user value (ex. session_id: "george")
# max server-side session-maps chats cached per provider (LRU) for stateless session reuse
DANYAPI_SESSION_CACHE_SIZE=128
# seconds an unused session/context stays reusable (0 = never expire)
DANYAPI_SESSION_TTL_SECONDS=3600
# seconds an unused session/context stays reusable (0 = never expire, currently 7 days)
DANYAPI_SESSION_TTL_SECONDS=604800
# directory for on-disk session cache (default = system temp dir, e.g. %TEMP%\danyapi)
DANYAPI_CACHE_DIR=
# set to 1/true/yes to disable on-disk cache entirely
DANYAPI_CACHE_DISABLED=
# log level: DEBUG, INFO, WARNING, ERROR

# LOGGING: level -> DEBUG, INFO, WARNING, ERROR
DANYAPI_LOG_LEVEL=INFO
# file path for persistent logs (empty = console only)
DANYAPI_LOG_FILE=
# max log file size in bytes before rotation
DANYAPI_LOG_MAX_BYTES=10485760
# number of rotated log files to keep
DANYAPI_LOG_BACKUP_COUNT=3

# set to 0/false/no/off to disable usage tracking (token counter stats)
DANYAPI_USAGE_ENABLED=1
# max recent usage records kept in memory for /v1/usage
DANYAPI_USAGE_MAX_RECORDS=1000
# auto-update to the latest GitHub release on each start (0 disables)
DANYAPI_AUTO_UPDATE=1
DANYAPI_AUTO_UPDATE=1

# custom User-Agent header for upstream requests to DeepSeek/Qwen (empty = default modern Chrome)
DANYAPI_USERAGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
31 changes: 0 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,7 @@ concurrency:
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v7

- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements-dev.txt

- name: Install system tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang clang-format clang-tidy nodejs

- name: Install dependencies
run: pip install -r requirements-dev.txt

- name: Build native PoW solver
run: clang -O3 -pthread -funroll-loops -flto -march=native -mtune=native -o danyapi/deepseek/pow_solver danyapi/deepseek/pow_solver.c

- name: Run tests
run: python tests.py -j 2

docker-build:
needs: test
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ pow_solver
.DS_Store
Thumbs.db
references
*.txt
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY danyapi ./danyapi

RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc libc6-dev nodejs \
&& apt-get install -y --no-install-recommends gcc libc6-dev nodejs curl \
&& gcc -O3 -pthread -funroll-loops -flto -fomit-frame-pointer -o danyapi/deepseek/pow_solver danyapi/deepseek/pow_solver.c \
&& apt-get purge -y gcc libc6-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED=1
ENV DANYAPI_HOST=0.0.0.0
ENV DANYAPI_PORT=8000

Expand Down
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def main() -> None:
import uvicorn

from danyapi.config import settings
from danyapi.logging import uvicorn_log_config
from danyapi.logging import log_startup_info, uvicorn_log_config

print(f"DanyAPI starting on {settings.host}:{settings.port}")
log_startup_info()
uvicorn.run(
"danyapi.api.openai:app",
host=settings.host,
Expand Down
4 changes: 3 additions & 1 deletion danyapi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def main() -> None:
)
sys.exit(1)
from danyapi.config import settings
from danyapi.logging import uvicorn_log_config
from danyapi.logging import log_startup_info, uvicorn_log_config

log_startup_info()

uvicorn.run(
"danyapi.api.openai:app",
Expand Down
Loading