@thomas-huang/caosi 0.1.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,24 @@
1
+ <p align="center">
2
+ <img src="assets/logo/caosi-icon.svg" width="88" height="88" alt="caosi">
3
+ </p>
4
+
1
5
  # caosi
2
6
 
3
7
  [中文](README.zh-CN.md)
4
8
 
5
- A local converter between LLM client protocols and named upstream providers. Point Claude Code, Codex, or Gemini CLI at `http://127.0.0.1:9999/{provider_name}`. Same protocol is passed through; OpenAI Chat, OpenAI Responses, Claude Messages, and Gemini are converted when they differ.
9
+ Keep using Claude Code, Codex, or Gemini CLI. Point them at your own upstream — no client switch.
6
10
 
7
- caosi is a converter, not a gateway.
11
+ Set the Base URL to `http://127.0.0.1:9999/{provider_name}`. OpenAI Chat, OpenAI Responses, Claude Messages, and Gemini convert in every direction; same protocol is passed through.
12
+
13
+ - A single static binary. No Docker.
14
+ - npm ships the binaries: no install script, nothing fetched from GitHub
15
+ - macOS, Linux, and Windows
16
+
17
+ ```bash
18
+ npm install -g @thomas-huang/caosi
19
+ ```
20
+
21
+ No Web UI, no OAuth, no key pool, no client-config rewrite. One process, one file, loopback only.
8
22
 
9
23
  ## Install
10
24
 
@@ -13,7 +27,7 @@ npm install -g @thomas-huang/caosi
13
27
  caosi --version
14
28
  ```
15
29
 
16
- Needs Node.js 18+ on macOS, Linux, or Windows (amd64). The npm package includes native binaries; there is no install script and nothing is fetched from GitHub at install time.
30
+ Needs Node.js 18+ on macOS or Linux (amd64 and arm64), or Windows (amd64). The npm package includes native binaries; there is no install script and nothing is fetched from GitHub at install time.
17
31
 
18
32
  ## Run
19
33
 
@@ -23,7 +37,7 @@ The first start writes a sample Provider File and exits. That is intentional: ca
23
37
  caosi
24
38
  ```
25
39
 
26
- Edit `~/.caosi/providers.jsonc`. Set `api_key` and `base_url`. If Claude Code will talk to an OpenAI-compatible upstream, keep `model` (for example `deepseek-chat`) so the upstream does not see `claude-*`.
40
+ Edit `~/.caosi/providers.jsonc`. Set `api_key` and `base_url`. If Claude Code will talk to an OpenAI-compatible upstream, keep `model` (for example `qwen/qwen3-coder`) so the upstream does not see `claude-*`.
27
41
 
28
42
  Start again:
29
43
 
@@ -35,26 +49,26 @@ curl -s http://127.0.0.1:9999/health
35
49
  ## Point Claude Code at it
36
50
 
37
51
  ```bash
38
- export ANTHROPIC_BASE_URL=http://127.0.0.1:9999/deepseek
52
+ export ANTHROPIC_BASE_URL=http://127.0.0.1:9999/openrouter
39
53
  export ANTHROPIC_API_KEY=dummy
40
54
  claude
41
55
  ```
42
56
 
43
- Replace `deepseek` with your Provider Name. caosi ignores the client key and uses the Provider's `api_key`. Claude Code sends `/v1/messages`; caosi converts when the upstream is not Claude.
57
+ Replace `openrouter` with your Provider Name. caosi ignores the client key and uses the Provider's `api_key`. Claude Code sends `/v1/messages`; caosi converts when the upstream is not Claude.
44
58
 
45
59
  ## Codex / OpenAI and Gemini CLI
46
60
 
47
61
  OpenAI SDK, Chat Completions, and Codex:
48
62
 
49
63
  ```bash
50
- export OPENAI_BASE_URL=http://127.0.0.1:9999/deepseek/v1
64
+ export OPENAI_BASE_URL=http://127.0.0.1:9999/openrouter/v1
51
65
  export OPENAI_API_KEY=dummy
52
66
  ```
53
67
 
54
68
  Gemini CLI (`~/.gemini/.env` or the environment):
55
69
 
56
70
  ```bash
57
- export GEMINI_API_BASE=http://127.0.0.1:9999/deepseek
71
+ export GEMINI_API_BASE=http://127.0.0.1:9999/openrouter
58
72
  ```
59
73
 
60
74
  ## Provider File
@@ -63,11 +77,11 @@ export GEMINI_API_BASE=http://127.0.0.1:9999/deepseek
63
77
 
64
78
  ```jsonc
65
79
  {
66
- "deepseek": {
67
- "base_url": "https://api.deepseek.com",
80
+ "openrouter": {
81
+ "base_url": "https://openrouter.ai/api",
68
82
  "protocol": "openai_chat",
69
83
  "api_key": "sk-...",
70
- "model": "deepseek-chat"
84
+ "model": "qwen/qwen3-coder"
71
85
  }
72
86
  }
73
87
  ```
@@ -79,19 +93,24 @@ export GEMINI_API_BASE=http://127.0.0.1:9999/deepseek
79
93
  | `claude_messages` | Claude Messages |
80
94
  | `gemini` | Gemini generateContent |
81
95
 
82
- - `model` is optional: when set, it replaces the client's model name on the upstream request.
96
+ - `model` is optional: when set, it replaces the client's model name on the upstream request, including when the protocols already match.
83
97
  - `headers` is optional extra request headers (for example OpenRouter).
84
- - `base_url` is a prefix. caosi does not strip `/v1`. Use the root the upstream actually expects (`https://api.deepseek.com`, not `https://api.deepseek.com/v1`).
98
+ - `base_url` is a prefix. caosi does not strip `/v1`. Use the root the upstream actually expects (`https://openrouter.ai/api`, not `https://openrouter.ai/api/v1`).
99
+
100
+ Same protocol is copied through. Different protocols remap the body: text, system instruction, tools, thinking, Thinking Signature, in-message images, documents, audio, and video, and Usage Details (reasoning / cache-read / cache-create token counts) are kept when the other protocol can express them; otherwise that part is dropped and the rest is sent. caosi does not fetch URLs or Files API objects (`file_id`, `fileUri`). Dedicated image, files, audio, video, and embeddings paths stay 404.
85
101
 
86
102
  ## Listen, health, reload
87
103
 
88
104
  - Loopback only: `127.0.0.1` (or `::1` via `--listen`). Default port `9999` (`--port`).
89
- - `GET /health`
105
+ - `GET /health` returns JSON with the current Provider Names.
90
106
  - Saving `providers.jsonc` hot-reloads; a bad file keeps the last good config.
107
+ - Request and JSON-response bodies over 32MiB are rejected (413).
91
108
  - Flags: `--config-dir`, `--port`, `--listen`, `--log-level`, `--version`.
92
109
 
93
110
  ## What it does not do
94
111
 
112
+ caosi is a converter, not a gateway.
113
+
95
114
  No Web UI, OAuth, failover, key pools, or rewriting your Claude Code / Codex / Gemini config files.
96
115
 
97
116
  ## Without Node.js
@@ -105,7 +124,7 @@ go install github.com/thomas-huang/caosi/cmd/caosi@latest
105
124
  go test ./...
106
125
  ```
107
126
 
108
- Domain language: [CONTEXT.md](CONTEXT.md). Decisions: [docs/adr](docs/adr).
127
+ Domain language: [CONTEXT.md](CONTEXT.md). Architecture: [docs/architecture.md](docs/architecture.md). Decisions: [docs/adr](docs/adr).
109
128
 
110
129
  To cut a release, push a tag `vX.Y.Z`. GitHub Actions builds the five binaries, writes checksums, creates the Release, and publishes `@thomas-huang/caosi` to npm with GitHub OIDC trusted publishing (no access token).
111
130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thomas-huang/caosi",
3
- "version": "0.1.4",
3
+ "version": "0.3.0",
4
4
  "description": "Local converter between LLM client protocols and named upstream providers",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/thomas-huang/caosi",
Binary file
Binary file
Binary file
Binary file
Binary file