Learn to Code with AI
Use AI assistants with Carbium docs safely: give them the right product context, ask for verifiable Solana code, and validate every RPC or Swap API step before production.
Use this page when you want an AI assistant to help build with Carbium without making it guess the product surface.
The useful pattern is simple: give the assistant the official Carbium docs context, ask for one small build step, then validate the generated code before it touches real keys, wallets, or mainnet transactions.
Part of the Carbium Solana infrastructure stack.
Start with the right context
Paste the relevant docs link into your assistant before asking for code:
Use the official Carbium docs as the source of truth:
https://docs.carbium.io
For better results, include the exact page that owns your task.
| Task | Give the assistant this page |
|---|---|
| Get a Swap API key and make a first quote request | Get your API key |
| Build a current quote-to-transaction flow | Q1 |
| Sign and submit a returned swap transaction | Executing Swaps |
| Fetch Solana data through Carbium RPC | Get Balance with Carbium |
| Choose the right key and auth format | Carbium Auth Matrix |
| Keep keys out of unsafe places | API Key Security Best Practices |
Do not ask the model to "use Carbium" without telling it whether you mean RPC, gRPC, Swap API, DEX UI, or Data. Those surfaces use different endpoints and auth patterns.
A prompt shape that works
Use prompts that name the product, language, endpoint family, and validation expectation.
Build a minimal TypeScript backend route that requests a SOL -> USDC quote
through Carbium Q1.
Source docs:
- https://docs.carbium.io/docs/q1
- https://docs.carbium.io/docs/api-key-security-best-practices
Requirements:
- use GET https://api.carbium.io/api/v2/quote
- use X-API-KEY from process.env.CARBIUM_API_KEY
- keep the key server-side
- use src_mint, dst_mint, amount_in, and slippage_bps
- do not sign or submit the transaction in this step
- include a short validation checklist
That prompt gives the assistant enough boundaries to avoid mixing Carbium's current Q1 flow with older v1 examples.
๐ Ask for one integration step at a time. A single prompt that asks for key creation, quoting, signing, submission, retries, monitoring, and UI code usually creates a harder review problem than a faster build.
What to include in every AI coding request
A good Carbium prompt usually includes five details:
- the language or framework you want
- the Carbium surface you are using
- the exact docs page or endpoint family
- where secrets must live
- what the generated code must not do yet
Example:
Write a Python script that calls Carbium RPC getHealth through
https://rpc.carbium.io/?apiKey=$CARBIUM_RPC_KEY.
Use the RPC key from an environment variable. Do not hard-code keys.
Print the raw JSON response and add comments showing where production
logging and retry policy would go.
If the assistant generates a different endpoint, auth pattern, or parameter family than the docs page shows, stop and correct the prompt before you continue.
Keep secrets out of prompts and client code
Never paste real Carbium keys, wallet private keys, seed phrases, session tokens, or production .env files into an AI assistant.
Use placeholders in prompts:
CARBIUM_RPC_KEY=rpc_live_xxx
CARBIUM_API_KEY=api_live_xxx
Then wire the real values through your local environment, secret manager, deployment platform, or backend runtime.
For browser, mobile, and wallet integrations, keep Carbium keys on your backend. The client should send user intent, not infrastructure credentials.
Review the generated code before running it
AI-generated code is a draft. For Solana work, review these points before execution:
| Check | Why it matters |
|---|---|
| Endpoint and auth match the docs page | Prevents wrong-key and wrong-surface failures |
| Token amounts use smallest units | Prevents trade-size mistakes |
| Private keys and API keys stay out of the prompt and client bundle | Reduces leak risk |
| Transaction code separates quote, sign, send, and confirm | Makes failures diagnosable |
| The code logs request IDs, response bodies, or transaction signatures safely | Helps support without leaking secrets |
| The script has a dry-run or simulation path where relevant | Catches errors before mainnet execution |
Use AI Coding Practices for the deeper review checklist.
A safer iteration loop
Work in small passes:
- ask for the smallest useful function
- compare endpoint, headers, and params against the docs
- run the code with placeholder or low-risk inputs
- inspect the raw response
- only then ask the assistant to add production handling
For swap flows, keep the boundary especially clear. Quote generation, transaction signing, RPC submission, and confirmation are separate stages. If the generated code hides those stages inside one large helper, ask the assistant to split them before production review.
When to move to the next docs page
| If the AI helped you... | Next page |
|---|---|
| Produce a first safe prompt and code draft | AI Coding Practices |
| Build a working quote request | Executing Swaps |
| Fetch wallet balance or RPC health | Sample Applications |
| Decide which key belongs to which surface | Carbium Auth Matrix |
๐ถ Use Carbium docs as the source of truth, let AI generate a small draft, then validate the generated code before it touches real keys or production transactions. Start from the broader platform at carbium.io.