How to authenticate with the API.
Get an API Key
- Go to Settings → API Keys
- Click Create API Key
- Copy the key (starts with
inf_)
Keep it Secret
- Don't commit to git
- Don't share publicly
- Use environment variables
bash
1export INFERENCE_API_KEY="inf_your_key"Using the Key
With SDKs
1from inferencesh import inference2import os3 4# Direct5client = inference(api_key="inf_your_key")6 7# From environment variable8client = inference(api_key=os.environ["INFERENCE_API_KEY"])With REST API
bash
1curl https://api.inference.sh/apps/run \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{"app": "infsh/echo", "input": {"message": "Hello!"}}'Install SDKs
1pip install inferencesh2 3# With async support4pip install inferencesh[async]Next
→ SDK Overview — Running apps, streaming, files