### Install OpenCode CLI on Windows (PowerShell) Source: https://docs.openadapter.dev/docs/integrations/opencode This PowerShell command installs OpenCode on Windows. It downloads the setup script and executes it, which includes setting up your API key and creating the configuration file. ```powershell irm "https://api.openadapter.in/api/setup/opencode-ps?key=YOUR_API_KEY" | iex ``` -------------------------------- ### Install Vision MCP Server (Bash) Source: https://docs.openadapter.dev/docs/mcp Installs the MCP server for image analysis using QwenVL. No local GPU is needed. ```bash curl -sL "https://api.openadapter.in/api/setup/mcp-vision?key=YOUR_API_KEY&tool=claude-code" | bash ``` -------------------------------- ### Install OpenCode CLI on macOS/Linux Source: https://docs.openadapter.dev/docs/integrations/opencode Use this command to install OpenCode on macOS or Linux systems. It fetches the setup script and executes it, configuring your API key and setting up the necessary files. ```bash curl -sL "https://api.openadapter.in/api/setup/opencode?key=YOUR_API_KEY" | bash ``` -------------------------------- ### Install Vision MCP Server (PowerShell) Source: https://docs.openadapter.dev/docs/mcp Installs the MCP server for image analysis using QwenVL via PowerShell. No local GPU is needed. ```powershell irm "https://api.openadapter.in/api/setup/mcp-vision-ps?key=YOUR_API_KEY&tool=claude-code" | iex ``` -------------------------------- ### Quick Install Aider with OpenAdapter Source: https://docs.openadapter.dev/docs/integrations/aider Installs Aider via pip and automatically configures environment variables by appending them to your shell's rc file. ```bash curl -sL "https://api.openadapter.in/api/setup/aider?key=YOUR_API_KEY" | bash ``` -------------------------------- ### Manual Setup for Claude Code Source: https://docs.openadapter.dev/docs/integrations/claude-code Manually set environment variables for Claude Code integration if not using the one-liner installer. Ensure ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are correctly configured. ```bash export ANTHROPIC_BASE_URL=https://api.openadapter.in export ANTHROPIC_AUTH_TOKEN=sk-cv-... ``` -------------------------------- ### Install Web Search MCP Server (Bash) Source: https://docs.openadapter.dev/docs/mcp Installs the MCP server for web search using SearXNG. Requires Docker and configures the server to run on port 8888. ```bash curl -sL "https://api.openadapter.in/api/setup/mcp-search?key=YOUR_API_KEY&tool=claude-code" | bash ``` -------------------------------- ### Install Claude Code with Bash Source: https://docs.openadapter.dev/docs/integrations/claude-code Recommended one-liner installation for Claude Code using Bash. This command sets up your API key and model mappings. ```bash curl -sL "https://api.openadapter.in/api/setup/claude-code?key=YOUR_API_KEY" | bash ``` -------------------------------- ### Install Pi Integration (macOS/Linux) Source: https://docs.openadapter.dev/docs/integrations/pi Installs the Pi integration using curl on macOS or Linux. This command configures the local Pi agent to use OpenAdapter as a custom provider. ```bash curl -sL "https://api.openadapter.in/api/setup/pi?key=YOUR_API_KEY" | bash ``` -------------------------------- ### Install Terminal Monitor MCP Server (Bash) Source: https://docs.openadapter.dev/docs/mcp Installs the MCP server for running and monitoring background processes. No Docker is required, and processes persist until the server restarts. ```bash curl -sL "https://api.openadapter.in/api/setup/mcp-terminal?key=YOUR_API_KEY&tool=claude-code" | bash ``` -------------------------------- ### Run LiveKit Agent in Production Mode Source: https://docs.openadapter.dev/docs/endpoints/speech-to-speech Deploy the LiveKit agent in production by running it with the 'start' command. ```bash python agent.py start ``` -------------------------------- ### Install OpenClaw on Windows (PowerShell) Source: https://docs.openadapter.dev/docs/integrations/openclaw Use this PowerShell command for installing OpenClaw on Windows. It sets up OpenAdapter as the default AI model provider. ```powershell irm "https://api.openadapter.in/api/setup/openclaw-ps?key=YOUR_API_KEY" | iex ``` -------------------------------- ### Install Pi Integration (Windows PowerShell) Source: https://docs.openadapter.dev/docs/integrations/pi Installs the Pi integration using PowerShell on Windows. This command configures the local Pi agent to use OpenAdapter as a custom provider. ```powershell irm "https://api.openadapter.in/api/setup/pi-ps?key=YOUR_API_KEY" | iex ``` -------------------------------- ### PearAI Model Configuration Source: https://docs.openadapter.dev/docs/integrations/pearai Example configuration for PearAI to define an AI model using the OpenAI provider and a custom API base. This setup is useful for connecting to services like OpenAdapter. ```yaml name: OpenAdapter version: 1.0.0 schema: v1 models: - name: GLM-4.7 provider: openai model: GLM-4.7 apiBase: https://api.openadapter.in/v1 apiKey: YOUR_API_KEY roles: - chat - edit - apply ``` -------------------------------- ### Install Claude Code with PowerShell Source: https://docs.openadapter.dev/docs/integrations/claude-code Recommended one-liner installation for Claude Code using PowerShell. This command sets up your API key and model mappings. ```powershell irm "https://api.openadapter.in/api/setup/claude-code-ps?key=YOUR_API_KEY" | iex ``` -------------------------------- ### Install Web Search MCP Server (PowerShell) Source: https://docs.openadapter.dev/docs/mcp Installs the MCP server for web search using SearXNG via PowerShell. Requires Docker and configures the server to run on port 8888. ```powershell irm "https://api.openadapter.in/api/setup/mcp-search-ps?key=YOUR_API_KEY&tool=claude-code" | iex ``` -------------------------------- ### Install OpenClaw on macOS/Linux Source: https://docs.openadapter.dev/docs/integrations/openclaw Use this command to install OpenClaw on macOS or Linux systems. It configures your environment to use OpenAdapter as a provider with a default model. ```bash curl -sL "https://api.openadapter.in/api/setup/openclaw?key=YOUR_API_KEY" | bash ``` -------------------------------- ### Convert Text to PDF Document (JavaScript) Source: https://docs.openadapter.dev/docs/tools/text2doc This JavaScript example shows how to use the fetch API to convert text into a PDF document. The API key should be stored securely, for example, in environment variables. ```javascript const res = await fetch('https://api.openadapter.in/v1/edge/text2doc', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "text": "# Hello\n\nWorld", "format": "pdf" }), }); const blob = await res.blob(); // Save blob to document.pdf ``` -------------------------------- ### Audio Transcription using Python Source: https://docs.openadapter.dev/docs/endpoints/audio-transcription Example of transcribing an audio file using the Python SDK. Ensure the 'client' object is initialized and the audio file is opened in binary read mode. ```python audio_file = open("recording.mp3", "rb") transcript = client.audio.transcriptions.create( model="whisper-large-v3", file=audio_file ) print(transcript.text) ``` -------------------------------- ### Install LiveKit Agent Dependencies Source: https://docs.openadapter.dev/docs/endpoints/speech-to-speech Install necessary Python packages for LiveKit agents, OpenAI plugin compatibility, environment variable loading, and WebSocket communication. ```bash pip install livekit-agents livekit-plugins-openai python-dotenv websockets numpy ``` -------------------------------- ### Install Terminal Monitor MCP Server (PowerShell) Source: https://docs.openadapter.dev/docs/mcp Installs the MCP server for running and monitoring background processes via PowerShell. No Docker is required, and processes persist until the server restarts. ```powershell irm "https://api.openadapter.in/api/setup/mcp-terminal-ps?key=YOUR_API_KEY&tool=claude-code" | iex ``` -------------------------------- ### Python End-to-End Example Source: https://docs.openadapter.dev/docs/vector-db/upsert A Python example demonstrating how to first generate embeddings using the /v1/embeddings endpoint and then upsert these embeddings along with their associated text into a vector collection. ```APIDOC ## Python End-to-End Example ### Description This example shows a complete workflow: generating embeddings for text chunks and then upserting these embeddings and their metadata into a vector collection using Python. ### Code ```python import requests API_KEY = "sk-cv-..." BASE = "https://api.openadapter.in" headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} chunks = ["chunk 1 text", "chunk 2 text"] # 1. Embed resp = requests.post(f"{BASE}/v1/embeddings", json={ "model": "qwen3-embedding-small", "input": chunks }, headers=headers) vectors = [d["embedding"] for d in resp.json()["data"]] # 2. Upsert requests.post(f"{BASE}/v1/vectors/collections/docs/points", json={ "points": [ {"id": i + 1, "vector": v, "payload": {"text": t}} for i, (v, t) in enumerate(zip(vectors, chunks)) ] }, headers=headers) ``` ``` -------------------------------- ### Example Error Response Source: https://docs.openadapter.dev/docs/advanced/error-handling This is an example of a JSON response when a rate limit is exceeded. ```json { "error": { "message": "Rate limit exceeded: monthly window (1500/1500 requests used)", "type": "rate_limit_error", "code": 429 } } ``` -------------------------------- ### LiveKit Agent Implementation with OpenAdapter Source: https://docs.openadapter.dev/docs/endpoints/speech-to-speech Configure and run a LiveKit agent using ParakeetSTT for speech-to-text, OpenAdapter for LLM and TTS, and compose them into an AgentSession. This script connects to the LiveKit room and starts the agent session. ```python import os from livekit.agents import Agent, AutoSubscribe, JobContext, WorkerOptions, cli from livekit.agents.voice import AgentSession from livekit.plugins import openai as lk_openai from parakeet_stt import ParakeetSTT async def entrypoint(ctx: JobContext) -> None: await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY) # 1. Parakeet STT stt = ParakeetSTT( ws_url=os.environ["PARAKEET_WS_URL"], api_key=os.environ["PARAKEET_API_KEY"], ) # 2. LLM via OpenAdapter llm = lk_openai.LLM( model=os.getenv("OPENADAPTER_LLM_MODEL", "Kimi-K2.5"), api_key=os.environ["OPENADAPTER_API_KEY"], base_url=os.environ["OPENADAPTER_BASE_URL"], ) # 3. TTS via OpenAdapter tts = lk_openai.TTS( model=os.getenv("OPENADAPTER_TTS_MODEL", "tts-1"), voice=os.getenv("OPENADAPTER_TTS_VOICE", "alloy"), api_key=os.environ["OPENADAPTER_API_KEY"], base_url=os.environ["OPENADAPTER_BASE_URL"], ) # 4. Compose agent = Agent(instructions="You are a helpful voice assistant.") session = AgentSession(stt=stt, llm=llm, tts=tts) # 5. Start await session.start(agent, room=ctx.room) if __name__ == "__main__": cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint)) ``` -------------------------------- ### Example Authorization Header Source: https://docs.openadapter.dev/docs/tools All requests to OpenAdapter tools require an 'Authorization' header with your API key. Generate or copy your API key from the dashboard. ```http Authorization: Bearer sk-cv-... ``` -------------------------------- ### Call API with Tool Definitions (JavaScript) Source: https://docs.openadapter.dev/docs/advanced/tool-calls This JavaScript example shows how to configure and send a chat completion request with tool definitions. The response is then checked to see if the model has decided to call a tool. ```javascript const tools = [{ type: 'function', function: { name: 'get_weather', description: 'Get weather for a city', parameters: { type: 'object', properties: { city: { type: 'string', description: 'City name' }, unit: { type: 'string', enum: ['celsius', 'fahrenheit'] }, }, required: ['city'], }, }, }]; const response = await client.chat.completions.create({ model: 'glm-4.7', messages: [{ role: 'user', content: "What's the weather in Tokyo?" }], tools, tool_choice: 'auto', }); const msg = response.choices[0].message; if (msg.tool_calls) { for (const call of msg.tool_calls) { console.log(`Call: ${call.function.name}(${call.function.arguments})`); } } ``` -------------------------------- ### Run LiveKit Agent in Development Mode Source: https://docs.openadapter.dev/docs/endpoints/speech-to-speech Start the LiveKit agent using the 'dev' command for hot-reloading, which is useful during development. ```bash python agent.py dev ``` -------------------------------- ### Send a message using JavaScript Source: https://docs.openadapter.dev/docs/endpoints/messages-api This JavaScript example shows how to send a message using the Anthropic SDK. Set your API key and the base URL for the OpenAdapter API. ```javascript import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic({ apiKey: '$API_KEY', baseURL: 'https://api.openadapter.in', }); const message = await client.messages.create({ model: 'GLM-4.7', max_tokens: 1024, messages: [ { role: 'user', content: 'What is the capital of France?' } ], }); console.log(message.content[0].text); ``` -------------------------------- ### Crawl Site Request using Python Source: https://docs.openadapter.dev/docs/tools/crawl Example of how to make a POST request to the /v1/tools/crawl endpoint using the Python requests library. Replace API_KEY with your actual OpenAdapter API key. ```python import requests resp = requests.post( "https://api.openadapter.in/v1/tools/crawl", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "url": "https://example.com", "max_pages": 5, "max_depth": 2, }, ) print(resp.json()) ``` -------------------------------- ### Audio Transcription using cURL Source: https://docs.openadapter.dev/docs/endpoints/audio-transcription Example of transcribing an audio file using cURL. Replace 'recording.mp3' with your audio file path. ```bash curl https://api.openadapter.in/v1/audio/transcriptions \ -H "Authorization: Bearer $API_KEY" \ -F model="whisper-large-v3" \ -F file="@recording.mp3" ``` -------------------------------- ### Call API with Tool Definitions (curl) Source: https://docs.openadapter.dev/docs/advanced/tool-calls This example shows how to make a curl request to the chat completions endpoint, including the definition of a 'get_weather' tool. Ensure you include the Authorization header with your API key. ```bash curl https://api.openadapter.in/v1/chat/completions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "glm-4.7", "messages": [{"role": "user", "content": "What is the weather in Tokyo?"}], "tools": [{ "type": "function", "function": { "name": "get_weather", "description": "Get weather for a city", "parameters": { "type": "object", "properties": { "city": {"type": "string"}, "unit": {"type": "string", "enum": ["celsius","fahrenheit"]} }, "required": ["city"] } } }], "tool_choice": "auto" }' ``` -------------------------------- ### Text-to-Speech with Python Source: https://docs.openadapter.dev/docs/endpoints/text-to-speech Generate speech from text using the OpenAdapter client library in Python. This example streams the response directly to a file named speech.mp3. ```python with client.audio.speech.with_streaming_response.create( model="tts-1", voice="alloy", input="Hello from OpenAdapter!" ) as response: response.stream_to_file("speech.mp3") ``` -------------------------------- ### Scrape URL using cURL Source: https://docs.openadapter.dev/docs/tools/scrape Example of how to scrape a webpage using cURL. Ensure you have your API key set as an environment variable OPENADAPTER_API_KEY. ```bash curl https://api.openadapter.in/v1/tools/scrape \ -H "Authorization: Bearer $OPENADAPTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com","mode":"fast"}' ``` -------------------------------- ### Create Embeddings with Python Source: https://docs.openadapter.dev/docs/endpoints/embeddings Example of how to create embeddings using the OpenAI Python client. Configure the client with your API key and base URL, then call the embeddings create method. This example also shows how to iterate through the response data to print the dimensions of each embedding. ```python from openai import OpenAI client = OpenAI( api_key="$API_KEY", base_url="https://api.openadapter.in/v1", ) resp = client.embeddings.create( model="qwen3-embedding-small", input=["Hello from OpenAdapter", "Batch item two"], ) for item in resp.data: print(len(item.embedding), "dimensions") ``` -------------------------------- ### Scrape URL using Python Source: https://docs.openadapter.dev/docs/tools/scrape Example of how to scrape a webpage using Python's requests library. Replace API_KEY with your actual OpenAdapter API key. ```python import requests resp = requests.post( "https://api.openadapter.in/v1/tools/scrape", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "url": "https://example.com", "mode": "fast", }, ) print(resp.json()) ``` -------------------------------- ### Create Embeddings with JavaScript Source: https://docs.openadapter.dev/docs/endpoints/embeddings Example of how to create embeddings using the OpenAI JavaScript client. Configure the client with your API key and base URL, then call the embeddings create method. This example demonstrates embedding a single string. ```javascript import OpenAI from 'openai'; const client = new OpenAI({ apiKey: '$API_KEY', baseURL: 'https://api.openadapter.in/v1', }); const resp = await client.embeddings.create({ model: 'jina-embeddings-v5', input: 'Single string input is also valid.', }); console.log(resp.data[0].embedding.length); ``` -------------------------------- ### Audio Transcription using JavaScript Source: https://docs.openadapter.dev/docs/endpoints/audio-transcription Example of transcribing an audio file using the JavaScript SDK. This requires Node.js and the 'fs' module for file stream creation. ```javascript import fs from 'fs'; const transcript = await client.audio.transcriptions.create({ model: 'whisper-large-v3', file: fs.createReadStream('recording.mp3'), }); console.log(transcript.text); ``` -------------------------------- ### Scrape URL using JavaScript Source: https://docs.openadapter.dev/docs/tools/scrape Example of how to scrape a webpage using JavaScript's fetch API. Ensure your API key is available as an environment variable OPENADAPTER_API_KEY. ```javascript const res = await fetch('https://api.openadapter.in/v1/tools/scrape', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "url": "https://example.com", "mode": "fast" }), }); console.log(await res.json()); ``` -------------------------------- ### Extract Data using JavaScript Source: https://docs.openadapter.dev/docs/tools/extract JavaScript example for extracting structured data. It uses the fetch API and requires the OPENADAPTER_API_KEY to be set in the environment variables. ```javascript const res = await fetch('https://api.openadapter.in/v1/tools/scrape/extract', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ url: 'https://example.com', selectors: [ { name: 'title', type: 'css', query: 'h1' }, { name: 'links', type: 'css', query: 'a', attribute: 'href', all: true }, ], mode: 'fast', }), }); console.log(await res.json()); ``` -------------------------------- ### Search for Images using JavaScript Source: https://docs.openadapter.dev/docs/tools/image-search This JavaScript example shows how to use the fetch API to search for images. It includes setting the Authorization header and sending JSON data in the request body. ```javascript const res = await fetch('https://api.openadapter.in/v1/tools/search/images', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "query": "cute cats", "num_results": 10 }), }); console.log(await res.json()); ``` -------------------------------- ### Search for Videos using JavaScript Source: https://docs.openadapter.dev/docs/tools/video-search This JavaScript example shows how to perform a video search using the fetch API. It sets the Authorization header and Content-Type, and sends the query and number of results in the request body. Ensure OPENADAPTER_API_KEY is set in your environment variables. ```javascript const res = await fetch('https://api.openadapter.in/v1/tools/search/videos', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "query": "react tutorial", "num_results": 10 }), }); console.log(await res.json()); ``` -------------------------------- ### Crawl Site Request using JavaScript Source: https://docs.openadapter.dev/docs/tools/crawl Example of how to make a POST request to the /v1/tools/crawl endpoint using JavaScript's fetch API. Ensure your API key is available in the environment variable OPENADAPTER_API_KEY. ```javascript const res = await fetch('https://api.openadapter.in/v1/tools/crawl', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "url": "https://example.com", "max_pages": 5, "max_depth": 2 }), }); console.log(await res.json()); ``` -------------------------------- ### Crawl Site Request using cURL Source: https://docs.openadapter.dev/docs/tools/crawl Example of how to make a POST request to the /v1/tools/crawl endpoint using cURL. Ensure you have your API key set as an environment variable OPENADAPTER_API_KEY. ```bash curl https://api.openadapter.in/v1/tools/crawl \ -H "Authorization: Bearer $OPENADAPTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com","max_pages":5,"max_depth":2}' ``` -------------------------------- ### Extract Data using cURL Source: https://docs.openadapter.dev/docs/tools/extract Example of how to extract structured data from a URL using cURL. Requires setting the OPENADAPTER_API_KEY environment variable. ```bash curl https://api.openadapter.in/v1/tools/scrape/extract \ -H "Authorization: Bearer $OPENADAPTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com", "selectors": [ {"name": "title", "type": "css", "query": "h1"}, {"name": "links", "type": "css", "query": "a", "attribute": "href", "all": true} ], "mode": "fast" }' ``` -------------------------------- ### Chat Completions API Request (curl) Source: https://docs.openadapter.dev/docs/endpoints/chat-completions Example of making a chat completions request using cURL. Ensure you have set the API key as an environment variable. ```bash curl https://api.openadapter.in/v1/chat/completions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "glm-4.7", "messages": [ {"role": "system", "content": "You are a helpful coding assistant."}, {"role": "user", "content": "Write a function to reverse a linked list."} ], "temperature": 0.7, "max_tokens": 2048 }' ``` -------------------------------- ### OCR Request using JavaScript Source: https://docs.openadapter.dev/docs/tools/ocr JavaScript example using fetch to send an image file for OCR. Requires Node.js 'fs' module and FormData/Blob polyfills if not in a browser environment. Ensure OPENADAPTER_API_KEY is set. ```javascript import fs from 'fs'; const form = new FormData(); form.append('file', new Blob([fs.readFileSync('image.png')])); const res = await fetch('https://api.openadapter.in/v1/edge/ocr', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}` }, body: form }); console.log(await res.json()); ``` -------------------------------- ### Chat Completions API Request (Python) Source: https://docs.openadapter.dev/docs/endpoints/chat-completions Example of making a chat completions request using the Python client library. This snippet prints the assistant's response and the total tokens used. ```python response = client.chat.completions.create( model="glm-4.7", messages=[ {"role": "system", "content": "You are a helpful coding assistant."}, {"role": "user", "content": "Write a Python function to reverse a linked list."} ], temperature=0.7, max_tokens=2048 ) print(response.choices[0].message.content) print(f"Tokens used: {response.usage.total_tokens}") ``` -------------------------------- ### Search News Articles with JavaScript Source: https://docs.openadapter.dev/docs/tools/news-search This JavaScript example shows how to use the fetch API to search for news articles. It sets the Authorization header and Content-Type, and sends the query and number of results in the request body. ```javascript const res = await fetch('https://api.openadapter.in/v1/tools/search/news', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "query": "OpenAI funding", "num_results": 10 }), }); console.log(await res.json()); ``` -------------------------------- ### Chat Completions with JSON Output Source: https://docs.openadapter.dev/docs/advanced/structured-output This example demonstrates how to use the chat completions endpoint to extract structured JSON data. By setting `response_format` to `{"type": "json_object"}` and providing a system prompt that requests JSON, the model will return a JSON object. ```APIDOC ## POST /v1/chat/completions ### Description Generates a structured JSON response based on the provided messages and system prompt. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for generation (e.g., "glm-4.7"). - **messages** (array) - Required - An array of message objects, each with a `role` (system, user, assistant) and `content`. - **role** (string) - Required - The role of the message sender. - **content** (string) - Required - The content of the message. - **response_format** (object) - Required - Specifies the desired output format. - **type** (string) - Required - The type of structured output, e.g., "json_object". ### Request Example ```json { "model": "glm-4.7", "messages": [ {"role": "system", "content": "Extract contact info as JSON."}, {"role": "user", "content": "John Smith, email john@example.com, phone 555-0123"} ], "response_format": {"type": "json_object"} } ``` ### Response #### Success Response (200) - **choices** (array) - An array containing the model's response(s). - **message** (object) - The message object from the model. - **content** (string) - The structured JSON content. #### Response Example ```json { "name": "John Smith", "email": "john@example.com", "phone": "555-0123" } ``` ``` -------------------------------- ### Configure Go OpenAI Client Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Set up the Go OpenAI client to use OpenAdapter's base URL. ```go package main import ( openai "github.com/sashabaranov/go-openai" ) config := openai.DefaultConfig("sk-cv-...") config.BaseURL = "https://api.openadapter.in/v1" client := openai.NewClientWithConfig(config) ``` -------------------------------- ### Configure Rust async-openai Client Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Initialize the Rust async-openai client with OpenAdapter's API base URL. ```rust use async_openai::{Client, config::OpenAIConfig}; let config = OpenAIConfig::new() .with_api_key("sk-cv-...") .with_api_base("https://api.openadapter.in/v1"); let client = Client::with_config(config); ``` -------------------------------- ### Configure PHP OpenAI Client Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Instantiate the PHP OpenAI client with the OpenAdapter base URI. ```php use OpenAI; $client = OpenAI::factory() ->withApiKey('sk-cv-...') ->withBaseUri('https://api.openadapter.in/v1') ->make(); ``` -------------------------------- ### Configure Ruby OpenAI Client Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Set up the Ruby OpenAI client to point to the OpenAdapter base URI. ```ruby require "openai" client = OpenAI::Client.new( access_token: "sk-cv-...", uri_base: "https://api.openadapter.in/v1", ) ``` -------------------------------- ### Configure Python OpenAI Client Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Use this snippet to initialize the OpenAI Python client with a custom base URL for OpenAdapter. ```python from openai import OpenAI client = OpenAI( api_key="sk-cv-...", base_url="https://api.openadapter.in/v1", ) ``` -------------------------------- ### Configure JavaScript OpenAI Client Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Initialize the OpenAI JavaScript client with the OpenAdapter base URL and API key. ```javascript import OpenAI from 'openai'; const client = new OpenAI({ apiKey: 'sk-cv-...', baseURL: 'https://api.openadapter.in/v1', }); ``` -------------------------------- ### Get Model Details Source: https://docs.openadapter.dev/docs/advanced/error-handling Retrieves detailed information about a specific model. ```APIDOC ## GET /v1/models/:id ### Description Gets details for a specific model. ### Method GET ### Endpoint /v1/models/:id ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the model to retrieve. ``` -------------------------------- ### Continue.dev Configuration for OpenAdapter Source: https://docs.openadapter.dev/docs/integrations/continue This YAML configuration sets up Continue.dev to use various OpenAdapter models, including chat, edit, and embed roles. Replace `YOUR_API_KEY` with your actual OpenAdapter API key. ```yaml name: OpenAdapter version: 1.0.0 schema: v1 models: - name: GLM-4.7 provider: openai model: GLM-4.7 apiBase: https://api.openadapter.in/v1 apiKey: YOUR_API_KEY roles: - chat - edit - apply - name: glm-4.7 provider: openai model: glm-4.7 apiBase: https://api.openadapter.in/v1 apiKey: YOUR_API_KEY roles: - chat - edit - apply - name: Qwen3 Embedding Small provider: openai model: qwen3-embedding-small apiBase: https://api.openadapter.in/v1 apiKey: YOUR_API_KEY roles: - embed ``` -------------------------------- ### List Collections Source: https://docs.openadapter.dev/docs/vector-db/collections Retrieve a list of all available vector collections associated with your API key. This is useful for managing your data and understanding your current setup. ```bash curl https://api.openadapter.in/v1/vectors/collections \ -H "Authorization: Bearer $OPENADAPTER_API_KEY" ``` -------------------------------- ### Set Environment Variables for Aider Source: https://docs.openadapter.dev/docs/integrations/aider Configure the OpenAI API key and base URL to point to the OpenAdapter service. This is necessary for Aider to communicate with the compatible backend. ```bash export OPENAI_API_KEY=sk-cv-... export OPENAI_API_BASE=https://api.openadapter.in/v1 aider --model openai/GLM-4.7 ``` -------------------------------- ### Create Embeddings with cURL Source: https://docs.openadapter.dev/docs/endpoints/embeddings Example of how to create embeddings using cURL. Ensure you replace `$API_KEY` with your actual API key and specify the desired model and input. ```bash curl https://api.openadapter.in/v1/embeddings \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3-embedding-small", "input": ["hello world", "second line"] }' ``` -------------------------------- ### Convert Text to PDF Document (Python) Source: https://docs.openadapter.dev/docs/tools/text2doc This Python script demonstrates how to convert text to a PDF document using the requests library. Replace API_KEY with your actual OpenAdapter API key. ```python import requests resp = requests.post( "https://api.openadapter.in/v1/edge/text2doc", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "text": "# Hello\n\nWorld", "format": "pdf", }, ) with open("document.pdf", "wb") as f: f.write(resp.content) ``` -------------------------------- ### Inspect a Collection Source: https://docs.openadapter.dev/docs/vector-db/collections Get detailed information about a specific collection, including its point count, vector size, and distance metric. This helps in monitoring and managing individual collections. ```bash curl https://api.openadapter.in/v1/vectors/collections/docs \ -H "Authorization: Bearer $OPENADAPTER_API_KEY" ``` -------------------------------- ### JavaScript Request for JSON Output Source: https://docs.openadapter.dev/docs/advanced/structured-output This JavaScript example demonstrates making a request to the chat completions endpoint with the `response_format` set to JSON. The response content is then parsed using `JSON.parse`. ```javascript const response = await client.chat.completions.create({ model: 'glm-4.7', messages: [ { role: 'system', content: 'Extract contact info as JSON.' }, { role: 'user', content: 'John Smith, email john@example.com, phone 555-0123' }, ], response_format: { type: 'json_object' }, }); const data = JSON.parse(response.choices[0].message.content); console.log(data); // {name: "John Smith", email: "john@example.com", phone: "555-0123"} ``` -------------------------------- ### Python Request for JSON Output Source: https://docs.openadapter.dev/docs/advanced/structured-output This Python code snippet shows how to use the OpenAdapter client to get JSON output. The response content needs to be parsed using `json.loads`. ```python response = client.chat.completions.create( model="glm-4.7", messages=[ {"role": "system", "content": "Extract contact info as JSON."}, {"role": "user", "content": "John Smith, email john@example.com, phone 555-0123"} ], response_format={"type": "json_object"} ) import json data = json.loads(response.choices[0].message.content) print(data) # {"name": "John Smith", "email": "john@example.com", "phone": "555-0123"} ``` -------------------------------- ### Environment Variables for LiveKit Agent Source: https://docs.openadapter.dev/docs/endpoints/speech-to-speech Configure LiveKit, OpenAdapter, and Parakeet STT services by setting these environment variables. Optional variables allow model and voice selection for LLM and TTS. ```bash # LiveKit LIVEKIT_URL=wss://your-livekit-project.livekit.cloud LIVEKIT_API_KEY=your_livekit_key LIVEKIT_API_SECRET=your_livekit_secret # OpenAdapter OPENADAPTER_API_KEY=sk-cv-your-key OPENADAPTER_BASE_URL=https://api.openadapter.in/v1 # Parakeet STT PARAKEET_API_KEY=your_parakeet_key PARAKEET_WS_URL=wss://edge.openadapter.in/parakeet/v1/audio/stream # Optional: model selection OPENADAPTER_LLM_MODEL=Kimi-K2.5 OPENADAPTER_TTS_MODEL=tts-1 OPENADAPTER_TTS_VOICE=alloy ``` -------------------------------- ### Generate Hybrid Embeddings (JavaScript) Source: https://docs.openadapter.dev/docs/tools/hybrid-embed This JavaScript snippet shows how to use the fetch API to get hybrid embeddings. It includes the necessary headers and JSON body, using 'bge-m3' as the model. ```javascript const res = await fetch('https://api.openadapter.in/v1/edge/embeddings/hybrid', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "input": "Search query", "model": "bge-m3" }), }); console.log(await res.json()); ``` -------------------------------- ### Set OPENADAPTER_API_KEY Environment Variable (Bash) Source: https://docs.openadapter.dev/docs/integrations/zed Set the API key for the OpenAdapter provider as an environment variable in your shell. Zed automatically maps the provider name to the corresponding uppercase environment variable. ```bash export OPENADAPTER_API_KEY="sk-cv-..." ``` -------------------------------- ### Generate Speech using JavaScript Source: https://docs.openadapter.dev/docs/tools/tts This JavaScript snippet demonstrates how to use the fetch API to convert text to speech. It sends a POST request with JSON payload and saves the response as a blob to speech.mp3. Ensure your OPENADAPTER_API_KEY is set in the environment variables. ```javascript const res = await fetch('https://api.openadapter.in/v1/audio/speech', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "model": "tts-1", "voice": "alloy", "input": "Hello, world!", "response_format": "mp3" }), }); const blob = await res.blob(); // Save blob to speech.mp3 ``` -------------------------------- ### Chat Completions API Request (JavaScript) Source: https://docs.openadapter.dev/docs/endpoints/chat-completions Example of making a chat completions request using the JavaScript client library. This snippet logs the assistant's response and the total tokens used to the console. ```javascript const response = await client.chat.completions.create({ model: 'glm-4.7', messages: [ { role: 'system', content: 'You are a helpful coding assistant.' }, { role: 'user', content: 'Write a function to reverse a linked list.' }, ], temperature: 0.7, max_tokens: 2048, }); console.log(response.choices[0].message.content); console.log(`Tokens used: ${response.usage.total_tokens}`); ``` -------------------------------- ### Configure curl for OpenAdapter Source: https://docs.openadapter.dev/docs/getting-started/libraries-sdks Set the required headers (Authorization, Content-Type) and base URL for making requests to OpenAdapter using curl. ```bash # Set these headers on every request: # Authorization: Bearer sk-cv-... # Content-Type: application/json # # Base URL: https://api.openadapter.in/v1 ``` -------------------------------- ### Web Search Request (cURL) Source: https://docs.openadapter.dev/docs/tools/web-search Use this cURL command to send a POST request to the web search endpoint. Ensure you replace $OPENADAPTER_API_KEY with your actual API key. ```bash curl https://api.openadapter.in/v1/tools/search \ -H "Authorization: Bearer $OPENADAPTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"query":"latest AI news","num_results":10,"language":"en"}' ``` -------------------------------- ### JavaScript Request for Audio Transcription Source: https://docs.openadapter.dev/docs/tools/stt This JavaScript example uses the fetch API and FormData to transcribe an audio file. It reads the file using Node.js 'fs' module and requires the API key to be set in the environment variable OPENADAPTER_API_KEY. ```javascript import fs from 'fs'; const form = new FormData(); form.append('file', new Blob([fs.readFileSync('recording.mp3')])); form.append('model', 'whisper-large-v3-turbo'); const res = await fetch('https://api.openadapter.in/v1/audio/transcriptions', { method: 'POST', headers: { Authorization: `Bearer ${process.env.OPENADAPTER_API_KEY}` }, body: form, }); console.log(await res.json()); ``` -------------------------------- ### Python RAG Implementation Source: https://docs.openadapter.dev/docs/vector-db/rag This Python script demonstrates the full RAG workflow: embedding a question, searching a vector collection, and then using the retrieved context to generate an answer via chat completion. Ensure you have the 'requests' library installed. ```python import requests API_KEY = "sk-cv-..." BASE = "https://api.openadapter.in" headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} def rag_query(question, collection="docs", top_k=5): # 1. Embed vec = requests.post(f"{BASE}/v1/embeddings", json={ "model": "qwen3-embedding-small", "input": [question] }, headers=headers).json()["data"][0]["embedding"] # 2. Search results = requests.post( f"{BASE}/v1/vectors/collections/{collection}/search", json={"vector": vec, "limit": top_k}, headers=headers, ).json()["results"] context = "\n\n".join(f"[{i+1}] {r['payload']['text']}" for i, r in enumerate(results)) # 3. Chat resp = requests.post(f"{BASE}/v1/chat/completions", json={ "model": "GLM-4.7", "messages": [ {"role": "system", "content": f"Answer using context:\n{context}"}, {"role": "user", "content": question}, ], }, headers=headers).json() return resp["choices"][0]["message"]["content"] print(rag_query("How do I create a collection?")) ``` -------------------------------- ### Python Chat Completion Source: https://docs.openadapter.dev/docs/getting-started/quick-start Connect to OpenAdapter using the OpenAI Python client. Configure the client with your API key and base URL. ```python from openai import OpenAI client = OpenAI( api_key="sk-cv-ாலத்தில்", base_url="https://api.openadapter.in/v1", ) response = client.chat.completions.create( model="glm-4.7", messages=[{"role": "user", "content": "Hello!"}], ) print(response.choices[0].message.content) ``` -------------------------------- ### Web Search Request (Python) Source: https://docs.openadapter.dev/docs/tools/web-search This Python script demonstrates how to make a POST request to the web search API using the requests library. Replace API_KEY with your actual API key. ```python import requests resp = requests.post( "https://api.openadapter.in/v1/tools/search", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "query": "latest AI news", "num_results": 10, "language": "en", }, ) print(resp.json()) ```