ChatCompletionContentPartTextSchema (llm/openaiSchemas.ts)

trueforge · packages/trueforge-core/src/core/llm/openaiSchemas.ts · typescript · MIT
ai

Defines Zod schemas for OpenAI Chat Completion content parts, including text, images, and audio, for use in OpenAPI-compliant LLM integrations.

// Source: https://github.com/truefoundry/trueforge | License: MIT | Copyright 2024-2026 TrueFoundry
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Canonical OpenAI wire schemas with OpenAPI component names.
 * Nested composites are rebuilt from decorated leaves so `$ref`s are preserved.
 */
import { z } from '@hono/zod-openapi';

export const ChatCompletionContentPartTextSchema = z
  .object({
    type: z.literal('text').describe('Text content part.'),
    text: z.string().describe('Plain-text content.'),
  })
  .openapi('ChatCompletionContentPartText');

export const ChatCompletionContentPartRefusalSchema = z
  .object({
    type: z.literal('refusal').describe('Model refusal content part.'),
    refusal: z.string().describe('Refusal message text.'),
  })
  .opena

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key