89 lines
2.8 KiB
Markdown
89 lines
2.8 KiB
Markdown
# API access
|
|
|
|
Members can use the co-op's models programmatically through an OpenAI-compatible
|
|
API. It's the same infrastructure that powers the chat — any OpenAI-compatible
|
|
client works.
|
|
|
|
## Quick facts
|
|
|
|
- **Base URL:** `https://gateway.inference.coop/v1`
|
|
- **Auth:** a bearer API key (create one in the [Member Dashboard](https://dashboard.inference.coop))
|
|
- **Format:** OpenAI chat completions — `POST https://gateway.inference.coop/v1/chat/completions`
|
|
- **Models:** see the [model list](models.md).
|
|
|
|
API usage draws from the **same monthly allowance as chat** — there's no separate
|
|
quota.
|
|
|
|
## Get a key
|
|
|
|
Log in to the [Member Dashboard](https://dashboard.inference.coop) and create an
|
|
API key. The key is an `sk-…` string you pass as a bearer token.
|
|
|
|
## Plain `curl`
|
|
|
|
```bash
|
|
curl https://gateway.inference.coop/v1/chat/completions \
|
|
-H "Authorization: Bearer sk-your-key" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"model": "deepseek-v4-1-flash", "messages": [{"role": "user", "content": "Hello"}]}'
|
|
```
|
|
|
|
## OpenAI SDK (Python, Node, etc.)
|
|
|
|
Point the SDK at our base URL and use your member key:
|
|
|
|
```python
|
|
from openai import OpenAI
|
|
|
|
client = OpenAI(
|
|
base_url="https://gateway.inference.coop/v1",
|
|
api_key="sk-your-key",
|
|
)
|
|
resp = client.chat.completions.create(
|
|
model="deepseek-v4-1-flash",
|
|
messages=[{"role": "user", "content": "Hello"}],
|
|
)
|
|
```
|
|
|
|
Any OpenAI-compatible client works the same way: set the base URL to
|
|
`https://gateway.inference.coop/v1` and the API key to your member key.
|
|
|
|
## Coding agents and other OpenAI-compatible clients
|
|
|
|
Any tool that speaks the OpenAI API works. Where a tool asks for provider or
|
|
endpoint configuration:
|
|
|
|
- **Base URL / endpoint:** `https://gateway.inference.coop/v1`
|
|
- **API type / protocol:** "OpenAI compatible" (or `openai-completions` where a
|
|
protocol string must be named) — not "Ollama", "Anthropic", or "Responses"
|
|
- **API key:** your member key (the `sk-…` string)
|
|
- **Model:** one from the [model list](models.md), e.g. `deepseek-v4-1-flash` or `greenpt/green-r`
|
|
|
|
A typical provider entry looks like:
|
|
|
|
```json
|
|
{
|
|
"providers": {
|
|
"inference-coop": {
|
|
"baseUrl": "https://gateway.inference.coop/v1",
|
|
"api": "openai-completions",
|
|
"apiKey": "sk-your-key",
|
|
"models": [
|
|
{ "id": "deepseek-v4-1-flash" },
|
|
{ "id": "gpt-oss-120b" },
|
|
{ "id": "glm-5-3-flash" },
|
|
{ "id": "greenpt/green-r" },
|
|
{ "id": "greenpt/green-l" }
|
|
]
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
If a tool's own docs show a local-server example (e.g.
|
|
`baseUrl: http://localhost:11434/v1` with `api: "openai-completions"`),
|
|
substitute our base URL and your member key for `apiKey` — the protocol value
|
|
stays the same. Some tools append `/chat/completions` to the base URL themselves;
|
|
if your base URL already ends in `/v1`, that's correct and you should not add
|
|
`/chat/completions`.
|