### POST /v1/chat/completions Source: https://docs.inceptionlabs.ai/capabilities/chat-completions Submit a request to the chat completions endpoint to get AI-generated responses. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint allows you to interact with the AI model to generate chat completions. You can specify the model, system message, and user message to guide the AI's response. ### Method POST ### Endpoint `https://api.inceptionlabs.ai/v1/chat/completions` ### Parameters #### Headers - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer $INCEPTION_API_KEY` #### Request Body - **model** (string) - Required - The AI model to use (e.g., `mercury-2`). - **messages** (array) - Required - An array of message objects. - **role** (string) - Required - The role of the message sender (`system` or `user`). - **content** (string) - Required - The content of the message. ### Request Example ```json { "model": "mercury-2", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a diffusion model?" } ] } ``` ### Response #### Success Response (200) - **choices** (array) - An array of message choices. - **message** (object) - The generated message. - **role** (string) - The role of the AI (`assistant`). - **content** (string) - The AI's response. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "A diffusion model is a type of generative model that learns to create data by reversing a process of gradually adding noise to the data." } } ] } ``` ``` -------------------------------- ### Authentication Source: https://docs.inceptionlabs.ai/capabilities/fim Export your API key as an environment variable for authentication. This example shows how to do it for macOS/Linux and Windows. ```APIDOC ## Authentication ### Description Export your API key as an environment variable in your terminal for authentication purposes. ### Method Environment Variable Export ### Parameters #### Environment Variable - **INCEPTION_API_KEY** (string) - Required - Your unique API key provided by Inception Labs. ### Request Example #### macOS / Linux ```bash export INCEPTION_API_KEY="your_api_key_here" ``` #### Windows ```cmd set INCEPTION_API_KEY=your_api_key_here ``` ``` -------------------------------- ### Configure Continue with InceptionLabs AI (YAML) Source: https://docs.inceptionlabs.ai/resources/continue This configuration file sets up the Continue extension to use the InceptionLabs AI provider with the 'mercury-2' model. It requires an API key and specifies the model's role as 'chat'. ```yaml name: Mercury 2 version: 1.0.0 schema: v1 models: - name: Mercury 2 provider: inception model: mercury-2 apiKey: INCEPTION_API_KEY roles: - chat ``` -------------------------------- ### API Request using Python Source: https://docs.inceptionlabs.ai/capabilities/tool-use Provides a Python example for making a chat completion request to the Inception Labs AI API. This snippet shows how to set up the API key and construct the request payload, similar to the cURL example. ```python # Python example would go here, demonstrating API call with the exported key and similar payload structure. ``` -------------------------------- ### Make API Request using cURL Source: https://docs.inceptionlabs.ai/capabilities/fim This example demonstrates how to make a request to the InceptionLabs AI FIM completions endpoint using cURL. It includes setting the API key in the Authorization header and providing model, prompt, and suffix in the request body. ```bash curl https://api.inceptionlabs.ai/v1/fim/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-edit", "prompt": "def fibonacci(", "suffix": "return a + b" }' ``` -------------------------------- ### Autocomplete API (cURL) Source: https://docs.inceptionlabs.ai/get-started/models Example of how to perform an autocomplete request using the v1/fim/completions endpoint with cURL. This demonstrates how to get code suggestions for a given prompt and suffix, utilizing models like Mercury Edit. ```shell curl https://api.inceptionlabs.ai/v1/fim/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-edit", "prompt": "def fibonacci(", "suffix": "return a + b", "max_tokens": 1000 }' ``` -------------------------------- ### Authentication Source: https://docs.inceptionlabs.ai/capabilities/chat-completions Export your API key as an environment variable for authentication. ```APIDOC ## Authentication ### Description Export your API key as an environment variable in your terminal for authentication purposes. ### Method Environment Variable Export ### Example (macOS / Linux) ```bash export INCEPTION_API_KEY="your_api_key_here" ``` ### Example (Windows) ```cmd set INCEPTION_API_KEY=your_api_key_here ``` ``` -------------------------------- ### API Request using cURL Source: https://docs.inceptionlabs.ai/capabilities/tool-use Demonstrates how to make a chat completion request to the Inception Labs AI API using cURL. It includes setting the API key, content type, and the request payload with a tool definition for getting weather information. ```bash curl https://api.inceptionlabs.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-2", "messages": [{"role": "user", "content": "What's the weather like in San Francisco?"}], "tools": [{"type": "function", "function": {"name": "get_weather", "description": "Get the current weather in a given location", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "City and state, e.g., 'San Francisco, CA'"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}}, "required": ["location", "unit"]}}}] }' ``` -------------------------------- ### Check All Status (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Provides a detailed status report for the OpenClaw gateway and all configured providers. This command is useful for in-depth troubleshooting when issues arise. ```bash openclaw status --all ``` -------------------------------- ### FIM Completions API Source: https://docs.inceptionlabs.ai/capabilities/fim Use the FIM completions endpoint to generate code completions based on a prompt and suffix. ```APIDOC ## POST /v1/fim/completions ### Description This endpoint generates code completions using the Fill-in-the-Middle (FIM) approach. Provide a model, a prompt, and a suffix to get a completion. ### Method POST ### Endpoint `https://api.inceptionlabs.ai/v1/fim/completions` ### Parameters #### Headers - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer $INCEPTION_API_KEY` #### Request Body - **model** (string) - Required - The model to use for completion (e.g., `mercury-edit`). - **prompt** (string) - Required - The beginning of the code snippet. - **suffix** (string) - Required - The end of the code snippet. ### Request Example ```json { "model": "mercury-edit", "prompt": "def fibonacci(", "suffix": "return a + b" } ``` ### Response #### Success Response (200) - **completion** (string) - The generated code completion. #### Response Example ```json { "completion": "n): if n <= 1: return n else: a, b = 0, 1 while b < n: a, b = b, a + b return a" } ``` ``` -------------------------------- ### Chat Completions API Source: https://docs.inceptionlabs.ai/capabilities/tool-use Make requests to the chat completions endpoint to interact with AI models. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint allows you to interact with AI models for chat-based completions. You can specify the model, messages, and tools to be used in the conversation. ### Method POST ### Endpoint `https://api.inceptionlabs.ai/v1/chat/completions` ### Parameters #### Headers - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer $INCEPTION_API_KEY` #### Request Body - **model** (string) - Required - The AI model to use (e.g., `mercury-2`). - **messages** (array) - Required - An array of message objects, each with a `role` (`user` or `assistant`) and `content`. - **tools** (array) - Optional - An array of tool definitions that the model can use. - **type** (string) - Required - The type of tool (e.g., `function`). - **function** (object) - Required - The function definition. - **name** (string) - Required - The name of the function. - **description** (string) - Optional - A description of what the function does. - **parameters** (object) - Required - The parameters the function accepts. ### Request Example ```json { "model": "mercury-2", "messages": [{"role": "user", "content": "What's the weather like in San Francisco?"}], "tools": [{ "type": "function", "function": { "name": "get_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": {"type": "string", "description": "City and state, e.g., 'San Francisco, CA'"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]} }, "required": ["location", "unit"] } } }] } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the response. - **object** (string) - Type of object returned (e.g., `chat.completion`). - **created** (integer) - Timestamp of creation. - **model** (string) - The model used for the completion. - **choices** (array) - An array of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The message content. - **role** (string) - Role of the message sender (`assistant`). - **content** (string) - The content of the assistant's reply. - **finish_reason** (string) - The reason the model stopped generating tokens. #### Response Example ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "mercury-2", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The weather in San Francisco is currently 15 degrees Celsius and sunny." }, "finish_reason": "stop" } ] } ``` ``` -------------------------------- ### List Available Models (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Lists all available AI models configured in OpenClaw, including custom providers like Inception. This command is used to verify that the 'inception/mercury-2' model is recognized. ```bash openclaw models list ``` -------------------------------- ### Interact with Inception AI Model using LangChain (Python) Source: https://docs.inceptionlabs.ai/resources/langchain This Python code demonstrates how to initialize and use the ChatOpenAI model from the langchain-openai library to interact with the InceptionLabs AI service. It retrieves the API key from environment variables and sends a query to the 'mercury-2' model. ```python import os from langchain_openai import ChatOpenAI api_key = os.environ["INCEPTION_API_KEY"] llm = ChatOpenAI( model="mercury-2", temperature=0.75, api_key=api_key, base_url="https://api.inceptionlabs.ai/v1" ) response = llm.invoke([("user", "What is a diffusion model?")]).content print(response) ``` -------------------------------- ### Restart OpenClaw Gateway (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Restarts the OpenClaw gateway service. This action is necessary to ensure that newly added provider configurations, such as the Inception Labs AI integration, are fully loaded and active. ```bash openclaw gateway restart ``` -------------------------------- ### Chat Completions API with Instant Reasoning Source: https://docs.inceptionlabs.ai/capabilities/instant This endpoint allows you to get near-instant responses from the Mercury-2 model by setting `reasoning_effort` to `instant`. This is suitable for applications requiring low-latency interactions. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint facilitates real-time chat completions using the Mercury-2 model with the `reasoning_effort` parameter set to `instant` for low-latency responses. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters None #### Request Body - **model** (string) - Required - The model to use for completions (e.g., "mercury-2"). - **messages** (array) - Required - An array of message objects, each with a `role` (system, user, assistant) and `content`. - **reasoning_effort** (string) - Optional - Set to "instant" for near-realtime responses. ### Request Example ```json { "model": "mercury-2", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a diffusion model?" } ], "reasoning_effort": "instant" } ``` ### Response #### Success Response (200) - **choices** (array) - An array of completion choices. - **message** (object) - The message object containing the AI's response. - **role** (string) - The role of the AI (e.g., "assistant"). - **content** (string) - The generated response content. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "A diffusion model is a type of generative model that learns to create data, such as images, by reversing a process that gradually adds noise to the data." } } ] } ``` ``` -------------------------------- ### Export API Key (macOS/Linux) Source: https://docs.inceptionlabs.ai/capabilities/structured-outputs This snippet shows how to export your InceptionLabs AI API key as an environment variable on macOS or Linux systems. This is crucial for authenticating your API requests securely. ```bash export INCEPTION_API_KEY="your_api_key_here" ``` -------------------------------- ### Chat Completions API (cURL) Source: https://docs.inceptionlabs.ai/get-started/models Example of how to make a chat completion request to the v1/chat/completions endpoint using cURL. This is useful for interacting with models like Mercury 2 for conversational AI tasks. ```shell curl https://api.inceptionlabs.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-2", "messages": [ {"role": "user", "content": "What is a diffusion model?"} ], "max_tokens": 10000 }' ``` -------------------------------- ### Make Chat Completions Request (cURL) Source: https://docs.inceptionlabs.ai/capabilities/chat-completions Demonstrates how to make a request to the InceptionLabs AI chat completions API using cURL. It includes setting the API key in the Authorization header and providing a JSON payload with model and message details. The request specifies the 'mercury-2' model and a system prompt. ```bash curl https://api.inceptionlabs.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-2", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a diffusion model?" } ] }' ``` -------------------------------- ### Check Model Status (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Displays the status of the primary model, authentication status, and the endpoint for the configured provider. This is used to confirm that Inception and Mercury 2 are correctly set up and authenticated. ```bash openclaw models status ``` -------------------------------- ### Configure OpenClaw with Inception Provider (JSON) Source: https://docs.inceptionlabs.ai/resources/open-claw Adds Inception Labs AI as a custom provider in the OpenClaw configuration file (`~/.openclaw/openclaw.json`). This JSON object specifies the base URL, API key (using the environment variable), API type, and available models from Inception. ```json { "models": { "mode": "merge", "providers": { "inception": { "baseUrl": "https://api.inceptionlabs.ai/v1", "apiKey": "${INCEPTION_API_KEY}", "api": "openai-completions", "models": [ { "id": "mercury-2", "name": "Mercury 2", "contextWindow": 128000, "maxTokens": 16384 } ] } } } } ``` -------------------------------- ### Add Fallback Model (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Adds 'inception/mercury-2' as a fallback model in OpenClaw. This means if the primary model fails or is unavailable, OpenClaw will attempt to use this model instead. ```bash openclaw models fallbacks add inception/mercury-2 ``` -------------------------------- ### Run Diagnostics (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Executes the OpenClaw diagnostic tools to check for and potentially fix common configuration issues. The `--fix` flag attempts to resolve detected problems automatically. ```bash openclaw doctor --fix ``` -------------------------------- ### Chat Completions API Source: https://docs.inceptionlabs.ai/capabilities/streaming This endpoint allows you to get chat completions from the Inception AI model. It supports streaming output for real-time responses. ```APIDOC ## POST /v1/chat/completions ### Description Generates chat completions using the specified model. Supports streaming output for interactive applications. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters None #### Request Body - **model** (string) - Required - The model to use for generating completions (e.g., "mercury-2"). - **messages** (array) - Required - An array of message objects representing the conversation history. - **role** (string) - Required - The role of the author of the message (e.g., "user", "assistant"). - **content** (string) - Required - The content of the message. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate in the completion. - **stream** (boolean) - Optional - If set to true, the response will be streamed back in chunks. ### Request Example ```json { "model": "mercury-2", "messages": [ {"role": "user", "content": "What is a diffusion model?"} ], "max_tokens": 1000, "stream": true } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the completion. - **object** (string) - Type of object returned (e.g., "chat.completion"). - **created** (integer) - Timestamp of creation. - **model** (string) - The model used for generation. - **choices** (array) - An array of completion choices. - **index** (integer) - Index of the choice. - **delta** (object) - The generated text delta. - **role** (string) - The role of the message (only present in the first chunk). - **content** (string) - The content of the message chunk. - **finish_reason** (string) - The reason the generation finished (e.g., "stop", "length"). #### Response Example (Streaming Chunk) ```json { "id": "chatcmpl-123", "object": "chat.completion.chunk", "created": 1677652288, "model": "mercury-2", "choices": [ { "index": 0, "delta": { "content": "A diffusion model" }, "finish_reason": null } ] } ``` #### Response Example (End of Stream) ```json { "id": "chatcmpl-123", "object": "chat.completion.chunk", "created": 1677652288, "model": "mercury-2", "choices": [ { "index": 0, "delta": {}, "finish_reason": "stop" } ] } ``` ``` -------------------------------- ### Make Real-time API Request (cURL) Source: https://docs.inceptionlabs.ai/capabilities/instant This cURL command demonstrates how to send a request to the Inception API to get a near-instant response from the Mercury 2 model. It includes setting the API key, specifying the model, providing a system and user message, and enabling the instant reasoning effort. ```bash curl https://api.inceptionlabs.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-2", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a diffusion model?" } ], "reasoning_effort": "instant" }' ``` -------------------------------- ### Make API Request for Code Editing (cURL) Source: https://docs.inceptionlabs.ai/capabilities/next-edit This example demonstrates how to use cURL to send a POST request to the InceptionLabs AI API for code editing. It includes setting the necessary headers and providing the request payload with model details and the code to be edited. ```bash curl https://api.inceptionlabs.ai/v1/edit/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d "{ \"model\": \"mercury-edit\", \"messages\": [ { \"role\": \"user\", \"content\": \"<|recently_viewed_code_snippets|>\n\n<|/recently_viewed_code_snippets|>\n\n<|current_file_content|>\ncurrent_file_path: solver.py\n'''''''''\nfunction: flagAllNeighbors\n----------\nThis function marks each of the covered neighbors of the cell at the given row\n<|code_to_edit|>\nand col as flagged.\n'''''''''\ndef flagAllNeighbors(board<|cursor|>, row, col): \n for r, c in b.getNeighbors(row, col):\n if b.isValid(r, c):\n b.flag(r, c)\n\n<|/code_to_edit|>\n<|/current_file_content|>\n\n<|edit_diff_history|>\n--- /c:/Users/test/testing/solver.py\n+++ /c:/Users/test/testing/solver.py\n@@ -6,1 +6,1 @@\n-def flagAllNeighbors(b, row, col): \n+def flagAllNeighbors(board, row, col): \n\n<|/edit_diff_history|>\" } ] }" ``` -------------------------------- ### Set Primary Model (OpenClaw CLI) Source: https://docs.inceptionlabs.ai/resources/open-claw Sets the 'mercury-2' model from the Inception provider as the primary model for OpenClaw. This command configures the default AI model that OpenClaw will use for interactions. ```bash openclaw models set inception/mercury-2 ``` -------------------------------- ### Make API Request using cURL Source: https://docs.inceptionlabs.ai/get-started/get-started This example demonstrates how to make a chat completion request to the Inception Labs AI API using cURL. It includes setting the necessary headers for content type and authorization, and provides a sample JSON payload with model and message content. ```curl curl https://api.inceptionlabs.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-2", "messages": [{"role": "user", "content": "What is a diffusion model?"}] }' ``` -------------------------------- ### Apply Code Edit Request using Curl Source: https://docs.inceptionlabs.ai/capabilities/apply-edit This example demonstrates how to use `curl` to send a 'mercury-edit' request to the InceptionLabs AI API. It includes setting the necessary headers and providing the original code and update snippet in the request body. The API merges the update into the original code. ```bash curl https://api.inceptionlabs.ai/v1/apply/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ -d '{ "model": "mercury-edit", "messages": [ { "role": "user", "content": "<|original_code|> class Calculator: """A simple calculator class.""" def __init__(self): self.history = [] def add(self, a, b): """Adds two numbers.""" result = a + b return result <|/original_code|> <|update_snippet|> // ... existing code ... def multiply(self, a, b): """Multiplies two numbers.""" result = a * b return result // ... existing code ... <|/update_snippet|>" } ] }' ``` -------------------------------- ### POST /v1/edit/completions Source: https://docs.inceptionlabs.ai/capabilities/next-edit This endpoint allows users to send code snippets and context to the Inception Labs AI for code editing suggestions. It supports providing recently viewed code, the current file's content, and edit history to guide the AI's response. ```APIDOC ## POST /v1/edit/completions ### Description This endpoint facilitates AI-driven code editing by accepting detailed context about the code being worked on. It leverages recently viewed snippets, the current file's state, and a history of edits to provide relevant code modifications. ### Method POST ### Endpoint /v1/edit/completions ### Parameters #### Request Body - **model** (string) - Required - The AI model to use for editing (e.g., "mercury-edit"). - **messages** (array) - Required - An array of message objects, typically containing a single user message. - **role** (string) - Required - The role of the message sender (e.g., "user"). - **content** (string) - Required - The detailed content of the user's request, including special tags for context: - `<|recently_viewed_code_snippets|>`: Placeholder for recently viewed code snippets. - `<|current_file_content|>`: Placeholder for the current file's content. - `<|edit_diff_history|>`: Placeholder for the edit history. ### Request Example ```json { "model": "mercury-edit", "messages": [ { "role": "user", "content": "<|recently_viewed_code_snippets|>\n\n<|/recently_viewed_code_snippets|>\n\n<|current_file_content|>\ncurrent_file_path: solver.py\n'''''''''\nfunction: flagAllNeighbors\n----------\nThis function marks each of the covered neighbors of the cell at the given row\n<|code_to_edit|>\nand col as flagged.\n'''''''''\ndef flagAllNeighbors(board<|cursor|>, row, col): \n for r, c in b.getNeighbors(row, col):\n if b.isValid(r, c):\n b.flag(r, c)\n\n<|/code_to_edit|>\n<|/current_file_content|>\n\n<|edit_diff_history|>\n--- /c:/Users/test/testing/solver.py\n+++ /c:/Users/test/testing/solver.py\n@@ -6,1 +6,1 @@\n-def flagAllNeighbors(b, row, col): \n+def flagAllNeighbors(board, row, col): \n\n<|/edit_diff_history|>" } ] } ``` ### Response #### Success Response (200) - The response will contain the AI's suggested code edits, typically enclosed within the `<|code_to_edit|>` tags in the `content` field of a message object. #### Response Example (The response structure mirrors the request, with the AI's edits inserted into the appropriate sections, particularly within the `<|code_to_edit|>` block.) ```json { "model": "mercury-edit", "choices": [ { "message": { "role": "assistant", "content": "<|recently_viewed_code_snippets|>\n\n<|/recently_viewed_code_snippets|>\n\n<|current_file_content|>\ncurrent_file_path: solver.py\n'''''''''\nfunction: flagAllNeighbors\n----------\nThis function marks each of the covered neighbors of the cell at the given row\n<|code_to_edit|>\nand col as flagged.\n'''''''''\ndef flagAllNeighbors(board, row, col): \n for r, c in board.getNeighbors(row, col):\n if board.isValid(r, c):\n board.flag(r, c)\n<|/code_to_edit|>\n<|/current_file_content|>\n\n<|edit_diff_history|>\n--- /c:/Users/test/testing/solver.py\n+++ /c:/Users/test/testing/solver.py\n@@ -6,1 +6,1 @@\n-def flagAllNeighbors(b, row, col): \n+def flagAllNeighbors(board, row, col): \n\n<|/edit_diff_history|>" } } ] } ``` ``` -------------------------------- ### Switch Model Mid-Session (OpenClaw Chat) Source: https://docs.inceptionlabs.ai/resources/open-claw Allows users to switch the AI model being used within an active chat session. This command can be used in any connected chat platform (e.g., Telegram, Discord, WhatsApp) to change the model to 'inception/mercury-2'. ```bash /model inception/mercury-2 ``` -------------------------------- ### Set Inception API Key Environment Variable (Shell) Source: https://docs.inceptionlabs.ai/resources/open-claw Sets the Inception API key as an environment variable for the current session. This key is required for OpenClaw to authenticate with Inception Labs AI. It is recommended to add this to your shell profile (`~/.zshrc` or `~/.bash_profile`) for persistence. ```shell export INCEPTION_API_KEY="your-api-key-here" ``` -------------------------------- ### Include API Key in Authorization Header (HTTP) Source: https://docs.inceptionlabs.ai/get-started/authentication This example demonstrates how to include your API key in the Authorization header of an HTTP request. It uses the 'Bearer' token type, which is standard for many API authentication schemes. ```http Authorization: Bearer $INCEPTION_API_KEY ``` -------------------------------- ### Python API Request with JSON Schema Response Source: https://docs.inceptionlabs.ai/capabilities/structured-outputs This Python code snippet demonstrates how to make a POST request to the InceptionLabs AI chat completions API. It includes setting up authentication via an environment variable, defining a JSON schema for the response, and sending a message for sentiment analysis. ```python import os import requests import json url = "https://api.inceptionlabs.ai/v1/chat/completions" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {os.environ["INCEPTION_API_KEY"]}", } response_schema = { "name": "Sentiment", "strict": True, "schema": { "type": "object", "properties": { "sentiment": { "type": "string", "enum": ["positive", "negative", "neutral"] }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 }, "key_phrases": { "type": "array", "items": {"type": "string"} } }, "required": ["sentiment", "confidence", "key_phrases"] }, } data = { "model": "mercury-2", "messages": [ { "role": "user", "content": "Analyze the sentiment of this text: 'I absolutely love this feature! It works perfectly and saves me so much time.'" } ], "response_format": { "type": "json_schema", "json_schema": response_schema }, "stream": False, } res = requests.post(url, headers=headers, data=json.dumps(data)) print(res.json()) ``` -------------------------------- ### Use AISuite Library for Inception API (Python) Source: https://docs.inceptionlabs.ai/get-started/get-started This Python code demonstrates how to use the AISuite library to interact with the Inception Labs AI API. It shows how to initialize the client with your API key and base URL, and make a chat completion request. ```python import os import aisuite as ai client = ai.Client( { "inception": {"api_key": os.environ["INCEPTION_API_KEY"], "base_url": "https://api.inceptionlabs.ai/v1"}, } ) response = client.chat.completions.create( model="inception:mercury-2", messages=[{"role": "user", "content": "What is a diffusion model?"}], max_tokens=1000 ) print(response.choices[0].message.content) ``` -------------------------------- ### Apply Edit Completions API Source: https://docs.inceptionlabs.ai/get-started/models The Apply Edit Completions API allows you to provide original code and an update snippet to generate a modified version of the code. ```APIDOC ## POST /v1/apply/completions ### Description Applies code edits using the Mercury Edit model. ### Method POST ### Endpoint `/v1/apply/completions` ### Parameters #### Request Body - **model** (string) - Required - The model to use (e.g., "mercury-edit"). - **messages** (object[]) - Required - An array of message objects. Use `<|original_code|>` and `<|update_snippet|>` tags to delineate code sections. - **max_tokens** (number) - Optional - Maximum number of tokens to generate. Default: 8192 for apply-edit. - **temperature** (number) - Optional - Controls randomness. Range: 0.0-1.0. Default: 0.0 for apply-edit. - **stop** (string[]) - Optional - Up to 4 sequences where the model will stop generating further tokens. - **stream** (boolean) - Optional - Whether to stream the response. Default: false. - **stream_options** (object) - Optional - Options for streaming. ### Request Example ```json { "model": "mercury-edit", "messages": [ {"role": "user", "content": "<|original_code|> class Calculator: """A simple calculator class.""" def __init__(self): self.history = [] def add(self, a, b): """Adds two numbers.""" result = a + b return result <|/original_code|> <|update_snippet|> // ... existing code ... def multiply(self, a, b): """Multiplies two numbers.""" result = a * b return result // ... existing code ... <|/update_snippet|>"} ], "max_tokens": 1000 } ``` ### Response #### Success Response (200) - **choices** (object[]) - An array of completion choices. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "class Calculator:\n """A simple calculator class.""" def __init__(self): self.history = [] def add(self, a, b): """Adds two numbers.""" result = a + b return result def multiply(self, a, b): """Multiplies two numbers.""" result = a * b return result" } } ] } ``` ``` -------------------------------- ### Edit Code Completions using cURL Source: https://docs.inceptionlabs.ai/get-started/models This cURL command demonstrates how to send a request to the v1/edit/completions endpoint. It includes necessary headers for content type and authorization, and a JSON payload containing the model, messages, and maximum tokens. The data is piped via standard input. ```bash curl https://api.inceptionlabs.ai/v1/edit/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $INCEPTION_API_KEY" \ --data-binary @- <<'JSON'\ { "model": "mercury-edit", "messages": [ {"role": "user", "content": "<|recently_viewed_code_snippets|> <|/recently_viewed_code_snippets|> <|current_file_content|> current_file_path: solver.py ''' function: flagAllNeighbors ---------- This function marks each of the covered neighbors of the cell at the given row <|code_to_edit|> and col as flagged. ''' def flagAllNeighbors(board<|cursor|>, row, col): for r, c in b.getNeighbors(row, col): if b.isValid(r, c): b.flag(r, c) <|/code_to_edit|> <|/current_file_content|> <|edit_diff_history|> --- /c:/Users/test/testing/solver.py +++ /c:/Users/test/testing/solver.py @@ -6,1 +6,1 @@ -def flagAllNeighbors(b, row, col): +def flagAllNeighbors(board, row, col): <|/edit_diff_history|>"} ], "max_tokens": 1000 } JSON ``` -------------------------------- ### File In Filling (FIM) Completions API Source: https://docs.inceptionlabs.ai/get-started/models The FIM Completions API is designed for code editing tasks, providing code completion suggestions based on the provided prompt and suffix. ```APIDOC ## POST /v1/fim/completions ### Description Provides code completion suggestions using the Mercury Edit model. ### Method POST ### Endpoint `/v1/fim/completions` ### Parameters #### Request Body - **model** (string) - Required - The model to use (e.g., "mercury-edit"). - **prompt** (string) - Required - The code preceding the desired completion. - **suffix** (string) - Required - The code following the desired completion. - **max_tokens** (number) - Optional - Maximum number of tokens to generate. Default: 512 for autocomplete. - **temperature** (number) - Optional - Controls randomness. Range: 0.0-1.0. Default: 0.0 for autocomplete. - **stop** (string[]) - Optional - Up to 4 sequences where the model will stop generating further tokens. - **stream** (boolean) - Optional - Whether to stream the response. Default: false. - **stream_options** (object) - Optional - Options for streaming. ### Request Example ```json { "model": "mercury-edit", "prompt": "def fibonacci(", "suffix": "return a + b", "max_tokens": 1000 } ``` ### Response #### Success Response (200) - **choices** (object[]) - An array of completion choices. #### Response Example ```json { "choices": [ { "text": "n): if n <= 1: return n else: return(fibonacci(n-1) + fibonacci(n-2))" } ] } ``` ``` -------------------------------- ### Set API Key Environment Variable (macOS/Linux) Source: https://docs.inceptionlabs.ai/index This snippet shows how to export your Inception API key as an environment variable on macOS or Linux systems. This is a common practice for securely managing API keys. ```bash export INCEPTION_API_KEY="your_api_key_here" ``` -------------------------------- ### Chat Completions API Source: https://docs.inceptionlabs.ai/get-started/models The Chat Completions API allows you to interact with the Mercury 2 model for conversational AI tasks. You can send messages and receive AI-generated responses. ```APIDOC ## POST /v1/chat/completions ### Description Provides chat completions using the Mercury 2 model. ### Method POST ### Endpoint `/v1/chat/completions` ### Parameters #### Request Body - **model** (string) - Required - The model to use (e.g., "mercury-2"). - **messages** (object[]) - Required - An array of message objects, each with a 'role' and 'content'. - **max_tokens** (number) - Optional - Maximum number of tokens to generate. Range: 1-50,000. Default: 8192. - **reasoning_effort** (string) - Optional - Controls the amount of reasoning. Options: `instant`, `low`, `medium`, `high`. Default: "medium". - **reasoning_summary** (boolean) - Optional - Whether to return a summary of the model's reasoning. Default: true. - **reasoning_summary_wait** (boolean) - Optional - Whether to delay the final response until the reasoning summary is ready. Default: false. - **temperature** (number) - Optional - Controls randomness. Range: 0.5-1.0. Default: 0.75. - **stop** (string[]) - Optional - Up to 4 sequences where the model will stop generating further tokens. - **stream** (boolean) - Optional - Whether to stream the response. Default: false. - **stream_options** (object) - Optional - Options for streaming, e.g., include usage information. - **diffusing** (boolean) - Optional - Enables diffusing effect for streaming. Should be true if stream is true. Default: false. - **tools** (object[]) - Optional - A list of tools the model may call. ### Request Example ```json { "model": "mercury-2", "messages": [ {"role": "user", "content": "What is a diffusion model?"} ], "max_tokens": 1000 } ``` ### Response #### Success Response (200) - **choices** (object[]) - An array of completion choices. - **usage** (object) - Usage statistics for the request. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "A diffusion model is a type of generative model..." } } ], "usage": { "prompt_tokens": 10, "completion_tokens": 100, "total_tokens": 110 } } ``` ``` -------------------------------- ### Code Completions API Source: https://docs.inceptionlabs.ai/capabilities/apply-edit This endpoint allows you to generate code completions or apply edits to existing code using various AI models. It requires authentication and a JSON payload specifying the model and messages. ```APIDOC ## POST /v1/apply/completions ### Description This endpoint is used to generate code completions or apply edits to existing code snippets using specified AI models. It supports structured input for original code and update snippets to intelligently merge changes. ### Method POST ### Endpoint /v1/apply/completions ### Parameters #### Query Parameters None #### Request Body - **model** (string) - Required - The AI model to use for the completion (e.g., "mercury-edit"). - **messages** (array) - Required - An array of message objects. - **role** (string) - Required - The role of the message sender (e.g., "user"). - **content** (string) - Required - The content of the message, typically containing code snippets formatted with specific tags. ### Request Example ```json { "model": "mercury-edit", "messages": [ { "role": "user", "content": "<|original_code|> class Calculator:\n \"\"\"A simple calculator class.\"\"\"\n def __init__(self): self.history = []\n\n def add(self, a, b):\n \"\"\"Adds two numbers.\"\"\"\n result = a + b\n return result\n<|/original_code|>\n\n<|update_snippet|>\n// ... existing code ...\ndef multiply(self, a, b):\n \"\"\"Multiplies two numbers.\"\"\"\n result = a * b\n return result\n// ... existing code ...\n<|/update_snippet|>" } ] } ``` ### Response #### Success Response (200) - **choices** (array) - An array of completion choices. - **message** (object) - The AI-generated message. - **role** (string) - The role of the AI (e.g., "assistant"). - **content** (string) - The generated or edited code. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "// ... existing code ...\ndef multiply(self, a, b):\n \"\"\"Multiplies two numbers.\"\"\"\n result = a * b\n return result\n// ... existing code ..." } } ] } ``` ```