@zenmux/rosetta-ai 0.18.0 → 0.19.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 +78 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Convert between OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, a
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install rosetta-ai
|
|
10
|
+
npm install @zenmux/rosetta-ai
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## How It Works
|
|
@@ -44,7 +44,7 @@ One converter instance handles the full round-trip for a single gateway route.
|
|
|
44
44
|
### OpenAI Chat Completions → Anthropic Messages
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
|
-
import { ChatCompletionToMessagesConverter } from "rosetta-ai";
|
|
47
|
+
import { ChatCompletionToMessagesConverter } from "@zenmux/rosetta-ai";
|
|
48
48
|
|
|
49
49
|
const converter = new ChatCompletionToMessagesConverter();
|
|
50
50
|
|
|
@@ -67,7 +67,7 @@ for await (const chunk of converter.convertStream(stream)) {
|
|
|
67
67
|
### Anthropic Messages → OpenAI Chat Completions
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
|
-
import { MessagesToChatCompletionConverter } from "rosetta-ai";
|
|
70
|
+
import { MessagesToChatCompletionConverter } from "@zenmux/rosetta-ai";
|
|
71
71
|
|
|
72
72
|
const converter = new MessagesToChatCompletionConverter();
|
|
73
73
|
|
|
@@ -90,7 +90,7 @@ for await (const event of converter.convertStream(stream)) {
|
|
|
90
90
|
### OpenAI Chat Completions → OpenAI Responses
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
|
-
import { ChatCompletionToResponsesConverter } from "rosetta-ai";
|
|
93
|
+
import { ChatCompletionToResponsesConverter } from "@zenmux/rosetta-ai";
|
|
94
94
|
|
|
95
95
|
const converter = new ChatCompletionToResponsesConverter();
|
|
96
96
|
|
|
@@ -109,7 +109,7 @@ for await (const chunk of converter.convertStream(responsesStream)) {
|
|
|
109
109
|
### OpenAI Responses → OpenAI Chat Completions
|
|
110
110
|
|
|
111
111
|
```typescript
|
|
112
|
-
import { ResponsesToChatCompletionConverter } from "rosetta-ai";
|
|
112
|
+
import { ResponsesToChatCompletionConverter } from "@zenmux/rosetta-ai";
|
|
113
113
|
|
|
114
114
|
const converter = new ResponsesToChatCompletionConverter();
|
|
115
115
|
|
|
@@ -128,7 +128,7 @@ for await (const event of converter.convertStream(ccStream)) {
|
|
|
128
128
|
### Anthropic Messages → OpenAI Responses
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
|
-
import { MessagesToResponsesConverter } from "rosetta-ai";
|
|
131
|
+
import { MessagesToResponsesConverter } from "@zenmux/rosetta-ai";
|
|
132
132
|
|
|
133
133
|
const converter = new MessagesToResponsesConverter();
|
|
134
134
|
|
|
@@ -147,7 +147,7 @@ for await (const event of converter.convertStream(responsesStream)) {
|
|
|
147
147
|
### OpenAI Responses → Anthropic Messages
|
|
148
148
|
|
|
149
149
|
```typescript
|
|
150
|
-
import { ResponsesToMessagesConverter } from "rosetta-ai";
|
|
150
|
+
import { ResponsesToMessagesConverter } from "@zenmux/rosetta-ai";
|
|
151
151
|
|
|
152
152
|
const converter = new ResponsesToMessagesConverter();
|
|
153
153
|
|
|
@@ -166,7 +166,7 @@ for await (const event of converter.convertStream(messagesStream)) {
|
|
|
166
166
|
### OpenAI Chat Completions → Google Gemini
|
|
167
167
|
|
|
168
168
|
```typescript
|
|
169
|
-
import { ChatCompletionToGeminiConverter } from "rosetta-ai";
|
|
169
|
+
import { ChatCompletionToGeminiConverter } from "@zenmux/rosetta-ai";
|
|
170
170
|
import { GoogleGenAI } from "@google/genai";
|
|
171
171
|
|
|
172
172
|
const converter = new ChatCompletionToGeminiConverter();
|
|
@@ -191,7 +191,7 @@ for await (const chunk of converter.convertStream(stream)) {
|
|
|
191
191
|
### Anthropic Messages → Google Gemini
|
|
192
192
|
|
|
193
193
|
```typescript
|
|
194
|
-
import { MessagesToGeminiConverter } from "rosetta-ai";
|
|
194
|
+
import { MessagesToGeminiConverter } from "@zenmux/rosetta-ai";
|
|
195
195
|
|
|
196
196
|
const converter = new MessagesToGeminiConverter();
|
|
197
197
|
|
|
@@ -210,7 +210,7 @@ for await (const event of converter.convertStream(geminiStream)) {
|
|
|
210
210
|
### OpenAI Responses → Google Gemini
|
|
211
211
|
|
|
212
212
|
```typescript
|
|
213
|
-
import { ResponsesToGeminiConverter } from "rosetta-ai";
|
|
213
|
+
import { ResponsesToGeminiConverter } from "@zenmux/rosetta-ai";
|
|
214
214
|
|
|
215
215
|
const converter = new ResponsesToGeminiConverter();
|
|
216
216
|
|
|
@@ -229,7 +229,7 @@ for await (const event of converter.convertStream(geminiStream)) {
|
|
|
229
229
|
### Google Gemini → OpenAI Chat Completions
|
|
230
230
|
|
|
231
231
|
```typescript
|
|
232
|
-
import { GeminiToChatCompletionConverter } from "rosetta-ai";
|
|
232
|
+
import { GeminiToChatCompletionConverter } from "@zenmux/rosetta-ai";
|
|
233
233
|
|
|
234
234
|
const converter = new GeminiToChatCompletionConverter();
|
|
235
235
|
|
|
@@ -248,7 +248,7 @@ for await (const chunk of converter.convertStream(ccStream)) {
|
|
|
248
248
|
### Google Gemini → Anthropic Messages
|
|
249
249
|
|
|
250
250
|
```typescript
|
|
251
|
-
import { GeminiToMessagesConverter } from "rosetta-ai";
|
|
251
|
+
import { GeminiToMessagesConverter } from "@zenmux/rosetta-ai";
|
|
252
252
|
|
|
253
253
|
const converter = new GeminiToMessagesConverter();
|
|
254
254
|
|
|
@@ -267,7 +267,7 @@ for await (const chunk of converter.convertStream(messagesStream)) {
|
|
|
267
267
|
### Google Gemini → OpenAI Responses
|
|
268
268
|
|
|
269
269
|
```typescript
|
|
270
|
-
import { GeminiToResponsesConverter } from "rosetta-ai";
|
|
270
|
+
import { GeminiToResponsesConverter } from "@zenmux/rosetta-ai";
|
|
271
271
|
|
|
272
272
|
const converter = new GeminiToResponsesConverter();
|
|
273
273
|
|
|
@@ -345,6 +345,71 @@ for await (const chunk of converter.convertStream(responsesStream)) {
|
|
|
345
345
|
| `file` content part | `inlineData` / `fileData` |
|
|
346
346
|
| `input_audio` | `inlineData` (audio mime) |
|
|
347
347
|
|
|
348
|
+
### Messages ↔ Responses
|
|
349
|
+
|
|
350
|
+
| Anthropic Messages | OpenAI Responses |
|
|
351
|
+
|---|---|
|
|
352
|
+
| `model` | `model` |
|
|
353
|
+
| `system` | `instructions` |
|
|
354
|
+
| `messages` (user/assistant with content blocks) | `input` (ResponseInputItem[]) |
|
|
355
|
+
| `max_tokens` | `max_output_tokens` |
|
|
356
|
+
| `temperature` | `temperature` |
|
|
357
|
+
| `top_p` | `top_p` |
|
|
358
|
+
| `tools` (custom) | `tools` (function) |
|
|
359
|
+
| `tools` (web_search_20250305) | `tools` (web_search) |
|
|
360
|
+
| `tool_choice` (auto/any/none/tool) | `tool_choice` (auto/required/none/function) |
|
|
361
|
+
| `tool_choice.disable_parallel_tool_use` | `parallel_tool_calls` |
|
|
362
|
+
| `thinking` (enabled/disabled/adaptive) | `reasoning.effort` |
|
|
363
|
+
| `output_config.format` (json_schema) | `text.format` (json_schema) |
|
|
364
|
+
| `metadata.user_id` | `metadata.user_id` |
|
|
365
|
+
| `service_tier` | `service_tier` |
|
|
366
|
+
| `tool_use` blocks | `function_call` items |
|
|
367
|
+
| `tool_result` blocks | `function_call_output` items |
|
|
368
|
+
| `image` blocks (base64/url) | `input_image` parts |
|
|
369
|
+
| `document` blocks (base64/url/text) | `input_file` / `input_text` parts |
|
|
370
|
+
|
|
371
|
+
### Messages ↔ Gemini
|
|
372
|
+
|
|
373
|
+
| Anthropic Messages | Google Gemini |
|
|
374
|
+
|---|---|
|
|
375
|
+
| `model` | `model` |
|
|
376
|
+
| `system` | `config.systemInstruction` |
|
|
377
|
+
| `messages` (user/assistant with content blocks) | `contents` (user/model roles) |
|
|
378
|
+
| `max_tokens` | `config.maxOutputTokens` |
|
|
379
|
+
| `temperature` | `config.temperature` |
|
|
380
|
+
| `top_p` | `config.topP` |
|
|
381
|
+
| `top_k` | `config.topK` |
|
|
382
|
+
| `stop_sequences` | `config.stopSequences` |
|
|
383
|
+
| `tools` (custom) | `config.tools[].functionDeclarations` |
|
|
384
|
+
| `tools` (web_search_20250305) | `config.tools` (googleSearch) |
|
|
385
|
+
| `tool_choice` (auto/any/none/tool) | `config.toolConfig.functionCallingConfig` (AUTO/ANY/NONE) |
|
|
386
|
+
| `thinking` (enabled/disabled/adaptive) | `config.thinkingConfig` |
|
|
387
|
+
| `output_config.format` (json_schema) | `config.responseMimeType` + `config.responseJsonSchema` |
|
|
388
|
+
| `tool_use` blocks | `functionCall` parts |
|
|
389
|
+
| `tool_result` blocks | `functionResponse` parts |
|
|
390
|
+
| `image` blocks (base64/url) | `inlineData` / `fileData` |
|
|
391
|
+
| `document` blocks (base64/url/text) | `inlineData` / `fileData` / text part |
|
|
392
|
+
| `thinking` blocks (with signature) | `thought` parts (`thoughtSignature`) |
|
|
393
|
+
|
|
394
|
+
### Responses ↔ Gemini
|
|
395
|
+
|
|
396
|
+
| OpenAI Responses | Google Gemini |
|
|
397
|
+
|---|---|
|
|
398
|
+
| `model` | `model` |
|
|
399
|
+
| `instructions` | `config.systemInstruction` |
|
|
400
|
+
| `input` (ResponseInputItem[]) | `contents` (user/model roles) |
|
|
401
|
+
| `max_output_tokens` | `config.maxOutputTokens` |
|
|
402
|
+
| `temperature` | `config.temperature` |
|
|
403
|
+
| `top_p` | `config.topP` |
|
|
404
|
+
| `tools` (function) | `config.tools[].functionDeclarations` |
|
|
405
|
+
| `tools` (web_search) | `config.tools` (googleSearch) |
|
|
406
|
+
| `tool_choice` | `config.toolConfig.functionCallingConfig` (AUTO/ANY/NONE) |
|
|
407
|
+
| `reasoning.effort` | `config.thinkingConfig` |
|
|
408
|
+
| `text.format` (json_schema/json_object) | `config.responseMimeType` + `config.responseJsonSchema` |
|
|
409
|
+
| `include` (logprobs) | `config.responseLogprobs` / `config.logprobs` |
|
|
410
|
+
| `function_call` items | `functionCall` parts |
|
|
411
|
+
| `function_call_output` items | `functionResponse` parts |
|
|
412
|
+
|
|
348
413
|
### Gemini Response / Stream
|
|
349
414
|
|
|
350
415
|
| Google Gemini | OpenAI / Anthropic |
|