Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.3 KB
Raw Blame
/**
 * OpenAI-compatible API for LibreChat agents.
 *
 * This module provides an OpenAI v1/chat/completions compatible interface
 * for interacting with LibreChat agents remotely via API.
 *
 * @example
 * ```typescript
 * import { createAgentChatCompletion, listAgentModels } from '@librechat/api';
 *
 * // POST /v1/chat/completions
 * app.post('/v1/chat/completions', async (req, res) => {
 *   await createAgentChatCompletion(req, res, dependencies);
 * });
 *
 * // GET /v1/models
 * app.get('/v1/models', async (req, res) => {
 *   await listAgentModels(req, res, { getAgents });
 * });
 * ```
 *
 * Request format:
 * ```json
 * {
 *   "model": "agent_id_here",
 *   "messages": [
 *     {"role": "user", "content": "Hello!"}
 *   ],
 *   "stream": true
 * }
 * ```
 *
 * The "model" parameter should be the agent ID you want to invoke.
 * Use the /v1/models endpoint to list available agents.
 */

export * from './types';
export * from './handlers';
export {
  createAgentChatCompletion,
  listAgentModels,
  convertMessages,
  validateRequest,
  isChatCompletionValidationFailure,
  createErrorResponse,
  sendErrorResponse,
  buildNonStreamingResponse,
  type ChatCompletionDependencies,
  type ChatCompletionValidationResult,
  type ChatCompletionValidationSuccess,
  type ChatCompletionValidationFailure,
} from './service';