MyRelay

← Back to the notebook

Point OpenCode at MyRelay Without Losing Budget Control

Start with a small task and a spending limit

OpenCode brings an AI coding assistant into your terminal, where it can help explain a project, suggest changes, and work through development tasks. Pointing it at a relay changes where its model requests go. Instead of managing separate provider connections, you can route supported requests through MyRelay and review their usage in one place.

Before connecting anything, choose a small first task and decide how much you are comfortable spending. Asking for an explanation of one function is a better connection test than requesting a project-wide refactor. A narrow task makes unexpected behavior easier to spot and limits the amount of context sent.

Prepare your account and keep the key private

Create a MyRelay account, then obtain your personal API key and check your available balance before opening a coding session. MyRelay is a personal, pay-as-you-go relay: one person uses one key and one budget across supported models.

Treat that key like a password. Keep it out of project content, shared configuration, screenshots, and version control. OpenCode's supported credential handling can vary by release and provider setup, so use the private credential mechanism documented for your installed version. An environment variable referenced by the provider configuration is preferable to embedding a secret in a configuration you might share.

Set up an OpenAI-compatible provider connection

Check the current OpenCode documentation for adding a custom OpenAI-compatible provider. The important distinction is between the provider connection and the model selected through it. The connection describes how OpenCode reaches MyRelay; the model entry describes what you want that connection to run.

Use a recognizable provider name, such as MyRelay, and select the OpenAI-compatible integration appropriate to your OpenCode version. MyRelay's API base is https://api.myapirelay.com. Check MyRelay's current connection instructions for the complete URL expected by that integration, including whether a version suffix is required. Avoid guessing or adding the same suffix twice.

Associate your private API key with this provider. Do not assume that choosing a familiar provider preset will automatically send traffic through the relay. Confirm that the custom connection uses the MyRelay endpoint rather than the original provider's default endpoint.

Add one model using its exact identifier

Start with one model rather than building a long selection list. DeepSeek V4 Flash is one option on MyRelay's menu to evaluate for your initial task. Check its current pricing and the capabilities available through the relay before choosing it for coding work.

Copy the exact API model identifier from MyRelay's current model information. A display name is not necessarily the identifier an API accepts, and changing capitalization or inventing a shortened name can cause a failed request. Add that model to your custom provider and select the provider-and-model combination in OpenCode.

If OpenCode asks for context limits or capability settings, use documented values. In particular, text generation alone does not establish that a connection supports the tool interactions needed for an agentic coding session.

Verify the route with one controlled request

Open a small, non-sensitive project and ask OpenCode to explain a short function without changing anything. Keep the request specific and avoid attaching unnecessary project context. Wait for the response before starting another task.

Then inspect the request in MyRelay. Members can see each request's tokens and cost. Check that the model is the one you selected and that the charge fits your expectations. This confirms the route more reliably than a successful-looking answer alone.

Expand gradually and troubleshoot without repeated retries

Once the explanation works, try one small, reversible edit and review the proposed changes. Tool use can introduce additional requests, so compare the cost of this task with your initial explanation. Neither a short prompt nor a brief final answer guarantees a small bill; project context and intermediate work also matter.

If something fails, stop and check the endpoint format, credential, model identifier, balance, and compatibility before retrying. Repeated attempts are not a useful substitute for identifying the error. Keep tasks bounded, inspect usage regularly, and expand the session only when both the behavior and the cost make sense.

More to read