Guides

Guide 04

Connect OpenCode and other coding agents to Tensic

Use Connect an app, the tensic CLI or OpenCode's own discovery to point OpenCode (or Claude Code, Codex, Grok, Hermes) at a Tensic project, then check the traffic in the project's logs.

On this page
  1. Connect OpenCode with "Connect an app"
  2. Run the commands and pick a Tensic model in OpenCode
  3. Connect an existing project with the tensic CLI
  4. Use OpenCode's built-in discovery instead of the CLI
  5. Show request prices in OpenCode
  6. Check OpenCode traffic in the project logs

Tensic can act as the model provider for OpenCode and other coding agents. Connect an app creates an inference project with the models you choose, a project API key and the commands to run in your terminal. All requests then show up in that project's logs, with token usage and cost.

Connect OpenCode with "Connect an app"

This is the fastest way to connect OpenCode. Tensic creates a new inference project for you.

  1. On the Tensic Home page, click Connect an app. The dialog offers Claude Code, OpenCode, Codex, Grok, Hermes and OpenAI-compatible app. Choose OpenCode. (The other choices work the same way and show the matching tensic <agent> on command.)
  2. In the Connect OpenCode dialog, set:
    • Team: the team that owns the new project. The project uses that team's models and budget. Choose the team first, because the list of models depends on it.
    • Project name: any name. Tensic normalises it, and the dialog shows the final name under the field (for example "it is created as opencode_test").
    • Models to serve: the models OpenCode can use. Type to filter the list. The first model you pick becomes the default (marked DEFAULT), but callers can choose any of the listed models on each request. You must pick at least one.
  3. Click Create and connect. Tensic creates the inference project and a project API key. (Back returns to the list of apps and Cancel closes the dialog.)
  4. The dialog now says "Project is ready." and shows three commands, plus the API KEY. The project ID in the second command is the number of the new project:
    curl -fsSL https://<your-instance>/install.sh | bash
    tensic login --project <project-id>
    tensic opencode on
    
    Copy the key now. This is the only time the full key is shown. It cannot be retrieved later. tensic login asks for the key and reads it without echoing it, so it never ends up in your shell history.
  5. If you'd rather not install the tensic CLI, click Prefer not to install anything? Use OpenCode's own discovery. The dialog then shows two commands with your key filled in:
    export TENSIC_API_KEY=<your key>
    opencode auth login https://<your-instance>/projects/<project-id>
    
    If you'd rather use a config file, click Prefer a static config? Show the opencode.json block and copy the JSON into your OpenCode configuration.
  6. Click Open project to go to the new project, or Done.

Everything in the dialog except the key itself is also on the project's Connect page.

Connect OpenCode dialog with team, project name and models to serve
Connect OpenCode result: key warning, commands and the discovery option (key hidden)

Run the commands and pick a Tensic model in OpenCode

With the tensic CLI:

  1. Open a terminal and run the three commands from the dialog. tensic login --project <project-id> asks for the project API key. tensic opencode on writes OpenCode's configuration.
  2. Start opencode and open the model picker (Select model). The Tensic project appears as its own provider group, with the models you selected.
  3. Pick a model and send a test prompt, for example "write me the Fibonacci series in Python".

With OpenCode's own discovery:

  1. Paste the export TENSIC_API_KEY=… command. This puts the key in an environment variable for the current shell.
  2. Run opencode auth login https://<your-instance>/projects/<project-id>. OpenCode reads the project's discovery file, stores the key and adds the project as a provider, with all of its models. You don't need to edit any YAML or run any scripts. opencode models then lists the models as tensic-project-<project-id>/<model>.
  3. Start opencode and pick a model as above.

The provider is registered at login, so you don't need to run /connect in OpenCode for it. Models that support reasoning offer reasoning-effort variants (for example low, high and max) in OpenCode.

OpenCode model picker showing the Tensic project as a provider

Connect an existing project with the tensic CLI

Every project has a Connect page (the Connect button at the top of the project). The Connect page starts with Connection details: the OpenAI base URL, the Anthropic base URL, an API key placeholder with a Create a key shortcut, and the served Models. Under Coding agents, the tensic CLI writes each agent's own config file. The agent then needs no flags and no wrapper script. There are tabs for Claude Code, OpenCode, Codex, Grok and Hermes.

  1. Open the project and click Connect.
  2. Under Coding agents, select the tab for your agent, for example OpenCode. The Claude Code tab is selected by default.
  3. Run the three commands shown. The project ID is already filled in:
    curl -fsSL https://<your-instance>/install.sh | bash
    tensic login --project <project-id>
    tensic opencode on
    
    The first command installs the tensic CLI. The second logs in to the project. The third configures the agent.
  4. When tensic login asks for a key, paste a project API key. If you don't have one yet, create one on the project's Access tab (see Teams, access and API keys).
  5. To undo, run tensic opencode off (or the matching command for your agent). This restores the agent's own settings exactly as they were.

Use the base URLs and models above for tools you configure by hand.

Connect page: Coding agents tabs and tensic CLI commands

Use OpenCode's built-in discovery instead of the CLI

If you'd rather not install anything, use OpenCode's own discovery mechanism. On the project's Connect page, click Prefer not to install anything? Use OpenCode's own discovery, or scroll to OpenCode discovery.

  • OpenCode reads an unauthenticated discovery file at GET /projects/<project-id>/.well-known/opencode. At login, it sets the project up as a provider: base URL, auth and every served model, with no manual config.
  • The OpenCode tab shows the two steps: create a project API key and export it as TENSIC_API_KEY, then run opencode auth login https://<your-instance>/projects/<project-id>.
  • The opencode.json tab shows a static config block you can paste yourself.
  • The cURL tab shows how to fetch the discovery file directly.

Below that, Agent descriptor (GET /projects/<project-id>/.well-known/agents) is the file the tensic CLI reads. It lists both base URLs, the served models with their context windows and which model to use for background work. It is unauthenticated and publishes no prices.

Discovery is specific to OpenCode. Other coding agents don't have an equivalent, so use the tensic CLI for them.

Show request prices in OpenCode

OpenCode can show what each request costs, but only if the discovery file includes prices. Tensic publishes the prices you set on the project, never the underlying model cost.

  1. Open the project and go to the Pricing tab.
  2. Enter the price you want to expose for each model, then save.
  3. Fetch the discovery file again (or log in again from OpenCode). It now contains the prices you entered, as cost entries (input, output and cache read) for each priced model.

The discovery file is open to anyone without authentication. That's how the well-known mechanism works. Only put prices there that you're happy to publish.

Check OpenCode traffic in the project logs

Every request OpenCode sends through Tensic is logged in the project, unless logging is turned off for it. This helps with debugging, and it also shows how a coding agent works: its system message, the messages it sends and the tools it calls.

  1. Open the project (it has the name you gave it in Connect an app).
  2. Click Logs.
  3. Each model call is one row (Model calls: "One row per call to the model"). Filter the list with All calls, Last 7 days or Search calls. If the project's Logging tab has Inference logging off, the calls are still counted but the rows show Not recorded; turn logging on to see requests and responses. A row shows when the call happened, the model, the Result (for example the finish reason), a short request summary such as "1 message", Tokens (input → output), Cost and Latency. A tool loop produces several rows for one user request.
  4. Select a row to open the Call detail: the result, endpoint (and whether it was streamed), latency, time, the request with the last user message, the response, the token counts and how the cost was calculated.

For the full log view, token and cost breakdown, redaction and retention, see Budgets, limits and logs.

Common questions

Do I have to create a project before connecting OpenCode?

No. Connect an app creates a new inference project, the API key and the commands in one step. To use a project you already have, open it and click Connect.

I closed the dialog without copying the key. What now?

The full key is only shown once. Create a new key on the project's Access tab, export it as TENSIC_API_KEY and run the login command again.

Which coding agents are supported?

Both Connect an app and the project's Connect page cover Claude Code, OpenCode, Codex, Grok and Hermes with tensic CLI commands. OpenCode can also use its own discovery file. For any other OpenAI- or Anthropic-compatible tool, choose OpenAI-compatible app and use the base URL and key.

Why don't I see the Tensic models in OpenCode?

Check that TENSIC_API_KEY is set in the same shell and that opencode auth login (or tensic login and tensic opencode on) finished successfully. The project appears as its own provider group in the model picker, and opencode models lists its models.

Can I choose which model OpenCode uses?

Yes. All models you selected under Models to serve appear in OpenCode. The first one is the default.

How do I stop routing an agent through Tensic?

Run tensic <agent> off, for example tensic opencode off. This restores the agent's own settings.

Does the discovery file expose my costs?

No. It only contains the prices you set on the project's Pricing tab. Model costs are never published there.