Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

index.ts

75 lines2.2 KB

1import { createFileRoute } from '@tanstack/react-router'
2​
3import { halGet, halPost } from '#/server/hal.ts'
4​
5export const serviceIndex = {
6 service: 'modelschemas',
7 description:
8 'Live AI model schemas: per-endpoint request/response JSON Schemas and model metadata for monitored providers, auto-refreshed.',
9 documentation: {
10 openapi: '/openapi.json',
11 agents: '/llms.txt',
12 },
13 _links: {
14 self: halGet('/v1'),
15 status: halGet('/v1/status'),
16 providers: halGet('/v1/providers'),
17 provider: halGet('/v1/providers/{provider}', {
18 example: '/v1/providers/anthropic',
19 }),
20 models: halGet(
21 '/v1/models{?activity,provider,capability,q,provenance,pricing}',
22 {
23 example: '/v1/models?activity=chat&q=claude',
24 },
25 ),
26 model: halGet('/v1/models/{provider}/{modelId}', {
27 example: '/v1/models/anthropic/claude-sonnet-4-5',
28 }),
29 schemaIndex: halGet('/v1/schemas', {
30 example: '/v1/schemas',
31 }),
32 schemas: halGet('/v1/schemas/{provider}', {
33 example: '/v1/schemas/anthropic',
34 }),
35 activitySchemas: halGet('/v1/schemas/{provider}/{activity}', {
36 example: '/v1/schemas/anthropic/chat',
37 }),
38 schema: halGet(
39 '/v1/schemas/{provider}/{activity}/{endpointId}{?kind,version}',
40 {
41 example: '/v1/schemas/anthropic/chat/v1%2Fmessages?kind=input',
42 },
43 ),
44 providerOpenapi: halGet('/v1/openapi/{provider}{?model,activity}', {
45 example: '/v1/openapi/anthropic',
46 }),
47 validate: halPost('/v1/validate', {
48 example: {
49 provider: 'anthropic',
50 endpointId: 'v1/messages',
51 kind: 'input',
52 payload: { model: 'claude-sonnet-4-5', max_tokens: 1024 },
53 },
54 }),
55 estimate: halPost('/v1/estimate', {
56 example: {
57 provider: 'openai',
58 model: 'gpt-4o',
59 usage: { input_tokens: 1200, output_tokens: 400 },
60 },
61 }),
62 changes: halGet('/v1/changes{?since,provider,type,cursor,limit,wait}', {
63 example: '/v1/changes?limit=20',
64 }),
65 agentDiscovery: halGet('/.well-known/agent-configuration'),
66 },
68​
69export const Route = createFileRoute('/v1/')({
70 server: {
71 handlers: {
72 GET: () => Response.json(serviceIndex),
73 },
74 },
75})