Connect OpenCode to MarsAI
Add MarsAI as an OpenAI compatible provider, map a public model ID and test the connection before starting an agent session.
MarsAI developer library
Concrete setup and implementation notes for MarsAI. Every article carries a review date and links to the live model catalog or pricing page where the details can change.
Add MarsAI as an OpenAI compatible provider, map a public model ID and test the connection before starting an agent session.
Use the OpenAI SDK with the MarsAI base URL while keeping credentials out of source code.
Conversation history belongs in the client. Route affinity keeps one session on one healthy target, but it cannot recreate messages that were omitted.
Use the status and error body to decide whether a request needs a configuration change, more credits or a bounded retry.
Compare the credit balances and billing methods, then estimate a paid request from the current published rates.
The model requests a tool; your application validates and runs it, then returns the result for the next model call.
Recover from temporary failures without treating partial output as complete or replaying side effects blindly.
Review dates move only after the instructions and examples are checked against the running PHP gateway. The model catalog and rates remain the source for model-specific details. If a command no longer matches the current client, send the page URL and the failing step through the contact form.