Skip to content

Add /v1/responses route scaffolding #2

@HXYerror

Description

@HXYerror

Part of #1.

Goal

Expose POST /v1/responses (and POST /responses) as a new Hono route, mirroring the existing /v1/chat/completions and /v1/messages patterns. This issue is route + request validation only; the upstream call lives in a separate issue.

Current state

src/server.ts:17–31 registers exactly:

```
/, /chat/completions, /v1/chat/completions, /models, /v1/models,
/embeddings, /v1/embeddings, /usage, /token,
/v1/messages, /v1/messages/count_tokens
```

There is no /responses directory under src/routes/.

Tasks

  • Create src/routes/responses/ mirroring the chat-completions/ layout
    • route.ts — Hono route with POST handler
    • types.ts — zod schema for the OpenAI Responses API request body (model, input, instructions, tools, tool_choice, temperature, top_p, max_output_tokens, reasoning, previous_response_id, store, include, stream, metadata, parallel_tool_calls, service_tier, truncation, user)
    • handler.ts — request → service → response wiring
  • Mount in src/server.ts at both /responses and /v1/responses
  • Plumb the rate-limit, manual-approval, and verbose-logging middleware that /chat/completions already uses
  • Return 501 (or pass through to a stub upstream call) until the service client lands

Acceptance criteria

  • POST /v1/responses returns a structured 4xx for malformed bodies (zod validation) instead of 500
  • Hitting it with a valid body produces traffic visible under --verbose logging
  • Existing /v1/chat/completions and /v1/messages regression tests still pass

File pointers

  • src/server.ts:17–31
  • src/routes/chat-completions/ (reference layout)
  • src/routes/messages/route.ts:10 (reference for nested route under /v1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    responses-apiOpenAI /v1/responses API support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions