/** * OpenAI-compatible adapter for MartinLoop. * * Routes agent execution to any endpoint that implements the OpenAI * Chat Completions API (`POST /v1/chat/completions`). This covers: * * Hosted via OpenRouter / Together.ai / Fireworks.ai: * DeepSeek-V3, DeepSeek-R1, Qwen3-235B, Mistral Large, Codestral, * Kimi k2, Nemotron-70B, and hundreds more. * * Local via Ollama / LM Studio / llama.cpp: * Llama 3.x, Mistral 7B, Phi-4, Gemma 3, any GGUF model. * * Usage: * # Defaults to OpenAI's hosted endpoint when MARTIN_OPENAI_BASE_URL is unset. * MARTIN_OPENAI_API_KEY=sk-... * MARTIN_OPENAI_MODEL= * martin-loop run "fix the bug" --engine openai * * # Or route to a third-party / self-hosted OpenAI-compatible endpoint: * MARTIN_OPENAI_BASE_URL=https://openrouter.ai/api * MARTIN_OPENAI_API_KEY=sk-or-... * MARTIN_OPENAI_MODEL=deepseek/deepseek-chat * martin-loop run "fix the bug" --engine openai * * Or for Ollama: * MARTIN_OPENAI_BASE_URL=http://localhost:11434 * MARTIN_OPENAI_MODEL=llama3.3 * martin-loop run "fix the bug" --engine openai */ import type { MartinAdapter } from "../core/index.js"; export interface OpenAiCompatibleAdapterOptions { /** Base URL of the OpenAI-compatible API. No trailing slash. */ baseUrl?: string; /** API key. Empty string for local (Ollama/LM Studio) endpoints. */ apiKey?: string; /** Model identifier passed as-is to the API (e.g. "deepseek/deepseek-chat"). */ model?: string; /** * System prompt prepended before the MartinLoop task prompt. * Default instructs the model to act as a focused coding assistant. */ systemPrompt?: string; /** Request timeout in milliseconds. Default: 300_000 (5 min). */ timeoutMs?: number; /** Verifier timeout in milliseconds. Default: 120_000. */ verifyTimeoutMs?: number; /** Working directory for git artifact collection and verification. */ workingDirectory?: string; /** Optional fetch override for testing. */ fetchImpl?: typeof fetch; } export declare const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com"; export declare function resolveOpenAiCompatibleRuntimeConfig(env?: NodeJS.ProcessEnv): { baseUrl: string; model?: string; apiKey: string; apiKeyConfigured: boolean; authPosture: "api_key" | "anonymous_or_local"; }; export declare function createOpenAiCompatibleAdapter(options: OpenAiCompatibleAdapterOptions): MartinAdapter;