Usage for Agents

Use this page when you want Codex, Claude Code, OpenClaw, Hermes, or another coding agent to modify an application that calls JoyToken through the Client SDKs.

What agents should know

TopicInstruction
Package choiceUse @joytoken/client-sdk-ts for TypeScript projects and github.com/joytoken/client-sdk-golang for Go projects
API keyRead JOY_TOKEN_API_KEY from server-side environment variables
ModelStart with auto; use a concrete JoyToken model key only when the workflow needs a pinned model
StreamingTreat chunks with metadata as observability data, not assistant text
ErrorsHandle JoyTokenAPIError in TypeScript and APIError in Go
Browser codeDo not put JoyToken API keys in frontend bundles

TypeScript prompt snippet

agent-instructions.md
Use @joytoken/client-sdk-ts for JoyToken model calls.
Create a JoyTokenClient with JOY_TOKEN_API_KEY from server-side env.
Use chat.completions.create() for non-streaming calls.
Use chat.completions.stream() for SSE streaming.
Do not expose JOY_TOKEN_API_KEY in browser code.
Handle JoyTokenAPIError and log status, requestId, and body.

Go prompt snippet

agent-instructions.md
Use github.com/joytoken/client-sdk-golang for JoyToken model calls.
Create a client with joytoken.NewClient(joytoken.WithAPIKey(os.Getenv("JOY_TOKEN_API_KEY"))).
Use CreateChatCompletion for non-streaming calls.
Use StreamChatCompletion for SSE streaming and close the stream.
Handle *joytoken.APIError with errors.As.

Code review checklist

CheckWhy it matters
Server-side API keyPrevents secret leakage
Request IDsMakes gateway logs, usage, and app logs easier to correlate
Streaming metadata handlingPrevents metadata JSON from appearing in the UI
Error classificationSeparates policy, quota, auth, and provider failures
Model choiceKeeps routing flexible unless a workflow requires pinning

For coding-agent product setup, use the Cookbook pages. This page is only about how agents should edit code that uses JoyToken Client SDKs.