Skip to content

Commit 3e9469d

Browse files
authored
Added OpenAI compatible "input" field support in /v1/responses API (#69)
Changes to /v1/responses API - Support for "endpoint" field for LiteLLM - Support for array of messages in the "input" field <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes **New Features** * Added LiteLLM provider support with per-model endpoint configuration * Enhanced multi-turn conversation support with conversation history preservation * Implemented system prompt override capability for personalized chat interactions * Extended input validation to support OpenAI-compatible conversation formats **Documentation** * Updated API documentation with LiteLLM configuration examples and endpoint handling guidance <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent a67e120 commit 3e9469d

File tree

8 files changed

+553
-60
lines changed

8 files changed

+553
-60
lines changed

agent-server/README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The server will start:
7575

7676
Send a task to a connected browser agent and get response.
7777

78-
**Request:**
78+
**Request (OpenAI):**
7979
```json
8080
{
8181
"input": "Click the submit button",
@@ -101,6 +101,39 @@ Send a task to a connected browser agent and get response.
101101
}
102102
```
103103

104+
**Request (LiteLLM):**
105+
```json
106+
{
107+
"input": "Navigate to google.com",
108+
"url": "about:blank",
109+
"wait_timeout": 5000,
110+
"model": {
111+
"main_model": {
112+
"provider": "litellm",
113+
"model": "qwen3:14b",
114+
"endpoint": "http://localhost:4000",
115+
"api_key": "sk-litellm-key"
116+
},
117+
"mini_model": {
118+
"provider": "litellm",
119+
"model": "qwen3:14b",
120+
"endpoint": "http://localhost:4000"
121+
},
122+
"nano_model": {
123+
"provider": "litellm",
124+
"model": "qwen3:14b",
125+
"endpoint": "http://localhost:4000"
126+
}
127+
}
128+
}
129+
```
130+
131+
**Endpoint Configuration:**
132+
- `endpoint` can be specified per model tier (e.g., `main_model.endpoint`)
133+
- Or at top-level `model.endpoint` to apply to all tiers
134+
- Falls back to `LITELLM_ENDPOINT` environment variable if not provided
135+
- Required for LiteLLM provider unless set via environment variable
136+
104137
**Response:**
105138
```json
106139
[

agent-server/nodejs/CLAUDE.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The eval-server is a **thin HTTP API wrapper for Browser Operator**. It provides
7070

7171
Primary endpoint for sending tasks to browser agents.
7272

73-
**Request:**
73+
**Request (OpenAI):**
7474
```json
7575
{
7676
"input": "Click the submit button",
@@ -84,6 +84,79 @@ Primary endpoint for sending tasks to browser agents.
8484
}
8585
```
8686

87+
**Request (LiteLLM with endpoint):**
88+
```json
89+
{
90+
"input": "Navigate to google.com",
91+
"url": "about:blank",
92+
"wait_timeout": 5000,
93+
"model": {
94+
"main_model": {
95+
"provider": "litellm",
96+
"model": "qwen3:14b",
97+
"endpoint": "http://localhost:4000"
98+
},
99+
"mini_model": {
100+
"provider": "litellm",
101+
"model": "qwen3:14b",
102+
"endpoint": "http://localhost:4000"
103+
},
104+
"nano_model": {
105+
"provider": "litellm",
106+
"model": "qwen3:14b",
107+
"endpoint": "http://localhost:4000"
108+
}
109+
}
110+
}
111+
```
112+
113+
**Note:** The `endpoint` field can be:
114+
- Specified per model tier (e.g., `main_model.endpoint`)
115+
- Specified at top-level (`model.endpoint`) to apply to all tiers
116+
- Omitted to use `LITELLM_ENDPOINT` environment variable
117+
118+
**Request (Conversation State - OpenAI Responses API format):**
119+
```json
120+
{
121+
"input": [
122+
{
123+
"role": "system",
124+
"content": "You are a web automation expert."
125+
},
126+
{
127+
"role": "user",
128+
"content": "Navigate to bloomberg.com"
129+
},
130+
{
131+
"role": "assistant",
132+
"content": "I've navigated to bloomberg.com. I can see the homepage."
133+
},
134+
{
135+
"role": "user",
136+
"content": "Summarize todays news"
137+
}
138+
],
139+
"url": "https://bloomberg.com",
140+
"model": {
141+
"main_model": {
142+
"provider": "litellm",
143+
"model": "gemma3:12b",
144+
"endpoint": "http://localhost:4000"
145+
}
146+
}
147+
}
148+
```
149+
150+
**Input Format Options:**
151+
1. **String format**: `"input": "Your message"` (simple, single message)
152+
2. **Conversation array**: `"input": [{role, content}, ...]` (multi-turn with history)
153+
154+
**Message Requirements:**
155+
- Each message needs `role` (`system`, `user`, or `assistant`) and `content` (string)
156+
- At least one `user` message required
157+
- System messages are extracted as system prompt
158+
- Maximum 100 messages, 10,000 characters each
159+
87160
**Response (OpenAI-compatible format):**
88161
```json
89162
[

agent-server/nodejs/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,105 @@ The `/v1/responses` endpoint provides an OpenAI-compatible interface for chat re
365365
```json
366366
{
367367
"input": "Your question or prompt here",
368+
"url": "about:blank",
369+
"wait_timeout": 5000,
368370
"model": {
369371
"main_model": {
370372
"provider": "openai",
371373
"model": "gpt-4",
372374
"api_key": "sk-..."
375+
},
376+
"mini_model": {
377+
"provider": "openai",
378+
"model": "gpt-4-mini",
379+
"api_key": "sk-..."
380+
},
381+
"nano_model": {
382+
"provider": "openai",
383+
"model": "gpt-3.5-turbo",
384+
"api_key": "sk-..."
373385
}
374386
}
375387
}
376388
```
377389

390+
**LiteLLM Provider with Endpoint:**
391+
```json
392+
{
393+
"input": "Your question or prompt here",
394+
"url": "about:blank",
395+
"model": {
396+
"main_model": {
397+
"provider": "litellm",
398+
"model": "qwen3:14b",
399+
"endpoint": "http://localhost:4000"
400+
},
401+
"mini_model": {
402+
"provider": "litellm",
403+
"model": "qwen3:14b",
404+
"endpoint": "http://localhost:4000"
405+
},
406+
"nano_model": {
407+
"provider": "litellm",
408+
"model": "qwen3:14b",
409+
"endpoint": "http://localhost:4000"
410+
}
411+
}
412+
}
413+
```
414+
415+
**Endpoint Configuration Priority:**
416+
1. Per-tier endpoint (e.g., `main_model.endpoint`) - highest priority
417+
2. Top-level endpoint (e.g., `model.endpoint`) - applies to all tiers
418+
3. Environment variable `LITELLM_ENDPOINT` - fallback
419+
4. Default: `http://localhost:4000` (LiteLLMProvider built-in default)
420+
421+
**Conversation State Format (OpenAI Responses API):**
422+
423+
You can also provide conversation history using an array of messages:
424+
425+
```json
426+
{
427+
"input": [
428+
{
429+
"role": "system",
430+
"content": "You are a web automation expert."
431+
},
432+
{
433+
"role": "user",
434+
"content": "Navigate to bloomberg.com"
435+
},
436+
{
437+
"role": "assistant",
438+
"content": "I've navigated to bloomberg.com. I can see the homepage."
439+
},
440+
{
441+
"role": "user",
442+
"content": "Summarize todays news"
443+
}
444+
],
445+
"url": "https://bloomberg.com",
446+
"model": {
447+
"main_model": {
448+
"provider": "litellm",
449+
"model": "gemma3:12b",
450+
"endpoint": "http://localhost:4000"
451+
}
452+
}
453+
}
454+
```
455+
456+
**Message Roles:**
457+
- `system` - System prompt/instructions (extracted and used as system prompt)
458+
- `user` - User messages
459+
- `assistant` - Previous assistant responses (for conversation history)
460+
461+
**Requirements:**
462+
- At least one `user` message must be present
463+
- Each message must have `role` and `content` fields
464+
- Maximum 100 messages per conversation
465+
- Maximum 10,000 characters per message
466+
378467
**Response Format:**
379468
```json
380469
[

0 commit comments

Comments
 (0)