跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.metask.ai/llms.txt

Use this file to discover all available pages before exploring further.

Any tool, library, or application that supports the OpenAI API works with 元任务 AI 网关 without code changes beyond two settings: the base URL (https://napi.origintask.cn/v1) and your gateway API key. This page shows the pattern for several popular clients so you can apply it to whatever tooling you already use.

curl (raw HTTP)

You can call the gateway directly with curl to test your API key, inspect raw responses, or script one-off requests.
terminal
curl https://napi.origintask.cn/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello!" }
    ]
  }'

LangChain

LangChain’s ChatOpenAI class accepts a custom base URL and API key, making it straightforward to swap in the gateway.
python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-4o-mini",
    openai_api_key="YOUR_API_KEY",
    openai_api_base="https://napi.origintask.cn/v1"
)

response = llm.invoke("Explain how a compiler works in two sentences.")
print(response.content)
Install the required package if you haven’t already:
terminal
pip install langchain-openai
For chains, agents, and other LangChain constructs, pass the same llm object as you normally would — the gateway is transparent to the rest of your LangChain code.

LlamaIndex

LlamaIndex’s OpenAI LLM class accepts the same api_base and api_key overrides:
python
from llama_index.llms.openai import OpenAI

llm = OpenAI(
    model="gpt-4o-mini",
    api_key="YOUR_API_KEY",
    api_base="https://napi.origintask.cn/v1"
)

response = llm.complete("What is retrieval-augmented generation?")
print(response.text)
Install the required package:
terminal
pip install llama-index-llms-openai

General configuration pattern

Regardless of the client, the pattern is always the same:
SettingValue
Base URL / API basehttps://napi.origintask.cn/v1
API keyYour 元任务 AI 网关 key
ModelAny identifier from Available Models
If a client has separate fields for organization or project ID, leave them blank — the gateway does not use them.
VS Code AI extensions (such as Continue, Codeium, or CodeGPT) and other AI coding tools typically have an OpenAI-compatible or Custom endpoint option in their settings. Set the base URL to https://napi.origintask.cn/v1 and paste your gateway API key to route those tools through the gateway as well.
Some clients validate the base URL by making a request to /models on startup. The gateway supports this endpoint, so model listing will work as expected.