Skip to content
Fungi
Esc
↑↓navigate↵open⌘Jpreview
On this page
Use Fungi

Call Fungi models with a Team key

Use Fungi's OpenAI-compatible model API from JavaScript, Python or curl. Issue a scoped Team key, set your base URL and call chat completions.

Call Fungi models with a Team key

Use Fungi's OpenAI-compatible model API from JavaScript, Python or curl. Issue a scoped Team key, set your base URL and call chat completions.

To use Fungi models from an OpenAI-compatible client, issue a Team key. Configure the client with that key and your Team’s base URL. The endpoint supports chat completions, model discovery, streaming and tool calls. The examples below use curl and the OpenAI SDKs for JavaScript and Python.

Fungi-funded model usage is paid from your Team’s balance. A Team key is a fungi_ credential for calling Fungi, not an OpenAI or Anthropic provider key. To give hosted Agents your own provider credentials, see Add your own model key.

Make a key

  1. In your Team, open Team keys.

  2. Under Issue a key, give it a name you will recognize later, like laptop script, and pick how long it lasts.

  3. Tick Generate with Fungi models (Team-funded). Leave the other rights off unless this key also needs to use your Computers.

  4. Choose Issue key. Copy the key now. It starts with fungi_ and is shown only once.

Treat the key like a password. Anyone who has it can spend your Team’s balance within the rights you selected. Team members can manage keys. Choose the shortest useful lifetime; revoke a key from Team keys if it is exposed.

Find your Team’s address

Your Team ID is the part after /teams/ in the address of your Team’s settings pages, such as Team keys. Your endpoint is:

Illustrative: replace <team-id> with your own Team ID; this address is a template, not a request.

https://fungi.computer/api/v1/teams/<team-id>

Try it

Put the key and Team ID in your shell:

Illustrative: these placeholder values must be replaced with the key you issued and your Team ID.

export FUNGI_KEY="fungi_..."
export FUNGI_TEAM="your-team-id"

List the models your Team can use:

curl "https://fungi.computer/api/v1/teams/$FUNGI_TEAM/models" \
  -H "Authorization: Bearer $FUNGI_KEY"

Ask for a reply:

curl "https://fungi.computer/api/v1/teams/$FUNGI_TEAM/chat/completions" \
  -H "Authorization: Bearer $FUNGI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "@fungi/luna",
    "messages": [{ "role": "user", "content": "Name three mushrooms I can grow at home." }]
  }'

The same call with the official OpenAI SDK for JavaScript:

import OpenAI from "openai";

const fungi = new OpenAI({
  apiKey: process.env.FUNGI_KEY,
  baseURL: `https://fungi.computer/api/v1/teams/${process.env.FUNGI_TEAM}`,
});

const reply = await fungi.chat.completions.create({
  model: "@fungi/luna",
  messages: [
    { role: "user", content: "Name three mushrooms I can grow at home." },
  ],
});

console.log(reply.choices[0].message.content);

And for Python:

Illustrative: this version requires the optional openai Python package in your Python environment, along with the same key and Team ID.

import os
from openai import OpenAI

fungi = OpenAI(
    api_key=os.environ["FUNGI_KEY"],
    base_url=f"https://fungi.computer/api/v1/teams/{os.environ['FUNGI_TEAM']}",
)

reply = fungi.chat.completions.create(
    model="@fungi/luna",
    messages=[{"role": "user", "content": "Name three mushrooms I can grow at home."}],
)

print(reply.choices[0].message.content)

What works

Endpoints GET /models and POST /chat/completions
Streaming "stream": true, plus stream_options.include_usage for token counts
Tools tools and tool_choice
Settings temperature, max_tokens or max_completion_tokens, reasoning_effort
Models GET /models lists those available to your Team.

Current Fungi addresses include @fungi/luna, @fungi/sol and @fungi/trip.

For Team-key requests, errors use OpenAI’s shape:

Status code Meaning
401 invalid_token The Authorization header is malformed, including an empty Bearer or a non-Fungi, non-JWT token.
401 invalid_api_key A fungi_ key is unknown, revoked, expired, or used against another Team’s address.
404 permission_denied The key lacks the model right, on both /models and /chat/completions.
403 permission_denied The Team is suspended, or the key loses authority at admission or spend time.

Omitting the Authorization header selects browser-session authentication, not Team-key authentication. Without a session, GET /models returns 401 {"error":"Unauthorized"}; a POST /chat/completions without the browser Origin returns 403 {"error":"Forbidden"}. These are not OpenAI-shaped errors.

Scope, revocation and recovery

The key’s Generate with Fungi models (Team-funded) right permits this endpoint; Computer discovery, creation, file access and command execution are separate rights. A key can cover all Team Computers or selected ones. For a model-only client, leave Computer rights off. You can change a key’s scope on Team keys or revoke it; a request already admitted may finish.

If a call returns 429 with insufficient_quota, check available Team credit in Billing. For rate_limit_exceeded or rate_limited, wait and retry rather than issuing another key. A 503 means the inference or key authority is unavailable; retry later. Revoked and expired keys cannot be recovered—issue a new key and replace it in your client without sharing it in logs or support messages.

Next: Work with Agents in your Team.

Last updated on

Was this page helpful?