Skip to content

Latest commit

 

History

163 Commits

Folders and files

Repository files navigation

Web2AI API

Unofficial & Experimental — Interfaces with undocumented web APIs (DeepSeek, Gemini, Meta AI). Intended for personal use, research, and local prototyping.

Desktop app and local OpenAI-compatible API gateway (http://127.0.0.1:8088) focused on DeepSeek (deepseek:deepseek-chat, deepseek:deepseek-reasoner), featuring Round-Robin load balancing, sticky sessions, SSE streaming, Vision, function tool calling, and Structured JSON Outputs (response_format).

What's New in v0.1.12

  • Client-defined function tools (tool_choice, parallel_tool_calls, strict schemas) with JSON/buffered SSE responses and x-web2ai-tool-retries header.
  • Tool-aware session history, SDK/agent tests (16/16 live app HTTP cases passed — see test report).
  • Gateway startup error reporting with retry support; frontend dev server on port 5290, API on 8088.

Supported Providers

Logo Provider Status Auth Features Docs
DeepSeek DeepSeek ✅ Active token Streaming, Reasoning, Function Tools, Structured JSON, Vision, Sessions Guide
Gemini Google Gemini 🚧 In Progress cookie Planned (hidden from /v1/models) —
Meta AI Meta AI 🚧 In Progress cookie Planned (hidden from /v1/models) —

Quick Start

cd desktop && bun install && cd ..
bun run dev

Frontend runs on http://localhost:5290; API listens on http://127.0.0.1:8088. Add a DeepSeek profile and API key in the app before calling from SDKs. To enforce API key auth in dev mode:

REQUIRE_API_KEY=true DISABLE_AUTH=false bun run dev

Previews & Floating Desktop Pet

Floating Pet Chat Preview

Provider Profiles API Playground
Provider Profiles API Playground
Pet Store (5 Pixel-Art Companions) Floating Pet Chat
Pet Store Floating Pet Chat
  • 5 Companions: Cyber Fox, Terminal Bot, Pixel Neko, Night Owl, Shiba Dev — with live typing/thinking/streaming reactions, quick-chat bar, and tray/hotkey controls.

API Reference (http://127.0.0.1:8088)

Auth: Release builds require Authorization: Bearer <key> or X-Api-Key. Debug builds skip auth unless REQUIRE_API_KEY=true.

Method Endpoint Description
GET /health, /docs Gateway status & interactive API docs
GET /v1/models List active provider:model models
POST /v1/chat/completions Chat (stream, tools, tool_choice, parallel_tool_calls, response_format, image_url, X-Session-Id)
GET/POST/PUT/DELETE /v1/profiles, /v1/profiles/{id} Manage upstream profiles (?type=deepseek)
GET/POST/DELETE /v1/keys, /v1/keys/revoke, /v1/keys/{key} Create, list, revoke, or delete API keys

Usage Examples

OpenAI SDK (Node.js) — Chat, Structured JSON & Tools

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://127.0.0.1:8088/v1",
  apiKey: process.env.WEB2AI_API_KEY ?? "YOUR_API_KEY",
});

const res = await client.chat.completions.create({
  model: "deepseek:deepseek-chat",
  messages: [{ role: "user", content: "Create an invoice for 2 books at 15 USD each." }],
  response_format: {
    type: "json_schema",
    json_schema: {
      name: "invoice",
      strict: true,
      schema: {
        type: "object",
        properties: { currency: { type: "string" }, total_amount: { type: "number" } },
        required: ["currency", "total_amount"],
        additionalProperties: false,
      },
    },
  },
});

curl — Chat, Sessions (X-Session-Id) & Vision (image_url)

# Chat completion (add -H "X-Session-Id: my-session" for sticky multi-turn history)
curl -s http://127.0.0.1:8088/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"deepseek:deepseek-chat","messages":[{"role":"user","content":"Hello!"}]}'
  • Vision: pass { "type": "image_url", "image_url": { "url": "..." } } in messages[].content.
  • Function Tool Calling: pass tools / tool_choice / parallel_tool_calls, execute returned tool_calls locally, and reply with role: "tool". See full Node.js & Python agent-loop examples and limits in docs/TOOL_CALLING.md.

Testing

cargo test --manifest-path desktop/src-tauri/Cargo.toml --lib   # Rust unit & mock HTTP tests
./tests/run_tool_contract.sh                                      # Node/Python contract & local agent tests (mocked)
./tests/run_all.sh                                                # Full Node/Python OpenAI SDK E2E suite (see tests/README.md)

Live HTTP tool matrix against a running app:

WEB2AI_HTTP_TOOL_TEST=1 WEB2AI_API_KEY='YOUR_API_KEY' \
  tests/python/.venv/bin/python -m pytest -v tests/python/test_tool_calling_http.py

Documentation

Installation Notes (macOS & Windows)

Release builds are ad-hoc signed without paid Apple Developer / Windows Authenticode certificates:

  • macOS (Gatekeeper): After dragging Web2AI.app to Applications, run xattr -cr /Applications/Web2AI.app once (or use System Settings → Privacy & Security → Open Anyway).
  • Windows (SmartScreen): Click More info → Run anyway.