Quickstart
Make your first SmartAPI request in three steps.
1. Create an API key#
Go to the API Keys page in the console and create a key. Keys
start with the prefix sk-. Copy it immediately and store it securely — the full
key is only shown once.
Treat your API key like a password. Never commit it to source control or expose it in client-side code.
2. Set your key as an environment variable#
export SMARTAPI_KEY="sk-your-key-here"3. Send your first request#
Using curl against the OpenAI-compatible endpoint:
curl https://api.smartapi.cc/api/openapi/v1/chat/completions \
-H "Authorization: Bearer $SMARTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"messages": [
{ "role": "user", "content": "Say hello to SmartAPI!" }
]
}'Using the OpenAI SDK (Python)#
from openai import OpenAI
client = OpenAI(
api_key="sk-your-key-here",
base_url="https://api.smartapi.cc/api/openapi/v1",
)
resp = client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": "user", "content": "Say hello to SmartAPI!"}],
)
print(resp.choices[0].message.content)Using the OpenAI SDK (Node.js)#
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.SMARTAPI_KEY,
baseURL: 'https://api.smartapi.cc/api/openapi/v1',
});
const resp = await client.chat.completions.create({
model: 'gpt-4.1',
messages: [{ role: 'user', content: 'Say hello to SmartAPI!' }],
});
console.log(resp.choices[0].message.content);What’s next#
- Prefer Claude models? See Messages for the Anthropic-compatible endpoint.
- Learn about streaming responses.
- Review error handling and rate limits.