openai-compatible-chat.ts 876 B

123456789101112131415161718192021222324
  1. import { Route, type RouteRoutedModelInput } from "../route/client"
  2. import { Endpoint } from "../route/endpoint"
  3. import { Framing } from "../route/framing"
  4. import * as OpenAIChat from "./openai-chat"
  5. const ADAPTER = "openai-compatible-chat"
  6. export type OpenAICompatibleChatModelInput = RouteRoutedModelInput
  7. /**
  8. * Route for non-OpenAI providers that expose an OpenAI Chat-compatible
  9. * `/chat/completions` endpoint. Reuses `OpenAIChat.protocol` end-to-end and
  10. * overrides only the route id so providers can be resolved per-family without
  11. * colliding with native OpenAI. Provider helpers configure the route endpoint
  12. * before model selection.
  13. */
  14. export const route = Route.make({
  15. id: ADAPTER,
  16. protocol: OpenAIChat.protocol,
  17. endpoint: Endpoint.path("/chat/completions"),
  18. framing: Framing.sse,
  19. })
  20. export * as OpenAICompatibleChat from "./openai-compatible-chat"