Other clients
Other OpenAI-compatible clients
Any client or SDK that supports a custom Base URL can connect to 2api in the OpenAI or Anthropic format.
Three things to fill in
Section titled “Three things to fill in”| Parameter | GPT (a GPT group) | Claude (CC-Max group) |
|---|---|---|
| Base URL | https://2api.dev/v1 |
https://2api.dev |
| API Key | sk-your-key |
sk-your-key |
| Model | Look it up with /v1/models |
Look it up with /v1/models |
The Claude group may only allow calls from the Claude Code client. If a third-party client reports only allows Claude Code clients, use the GPT group instead, or use Claude in Claude Code.
Code examples
Section titled “Code examples”from openai import OpenAI
client = OpenAI(base_url="https://2api.dev/v1", api_key="sk-your-key")resp = client.chat.completions.create( model="model-name", messages=[{"role": "user", "content": "Hello"}],)print(resp.choices[0].message.content)import anthropic
client = anthropic.Anthropic(base_url="https://2api.dev", api_key="sk-your-key")msg = client.messages.create( model="model-name", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}],)print(msg.content[0].text)curl https://2api.dev/v1/chat/completions \ -H "Authorization: Bearer sk-your-key" \ -H "Content-Type: application/json" \ -d '{"model": "model-name", "messages": [{"role": "user", "content": "Hello"}]}'Cursor
Section titled “Cursor”In Cursor’s settings, turn on Override OpenAI Base URL and enter https://2api.dev/v1. Enter your key as the API key, then add the model name by hand. A few limits:
- Cursor sends requests from its own servers, so it only accepts a public address (2api.dev works).
- Don’t give a custom model the same name as one of Cursor’s built-in models.
- Agent mode sometimes reports
Missing required parameter: 'messages'. This is a compatibility problem on Cursor’s side. If you hit this error with GPT in Cursor, install the Codex extension instead.