Examples
Practical examples to help you integrate the iNwealth API into your application.
Simple question
A single-turn question about French tax law:
curl -X POST https://api.inwealth.fr/api/agent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_your_key_here" \
-d '{
"messages": [
{"role": "user", "content": "What are the tax brackets in France for 2025?"}
],
"session_id": "demo-001",
"residence": "fr",
"language": "en"
}'
For simple factual questions, leave effort and extended_thinking at their defaults to minimize token usage.
Multi-turn conversation
The API is stateless — send the full conversation history each time. Reuse the same session_id to benefit from prompt caching.
# Turn 1
curl -X POST https://api.inwealth.fr/api/agent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_your_key_here" \
-d '{
"messages": [
{"role": "user", "content": "What is the PER in France?"}
],
"session_id": "demo-multi-001",
"residence": "fr",
"language": "en"
}'
# Turn 2 — include the full history
curl -X POST https://api.inwealth.fr/api/agent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_your_key_here" \
-d '{
"messages": [
{"role": "user", "content": "What is the PER in France?"},
{"role": "assistant", "content": "The PER (Plan d'\''Epargne Retraite) is a retirement savings plan introduced in 2019..."},
{"role": "user", "content": "What are the tax deduction limits for 2025?"}
],
"session_id": "demo-multi-001",
"residence": "fr",
"language": "en"
}'
In the assistant message, include the full text that the agent returned (all concatenated delta events). Do not include metadata.
Cross-border scenario
For complex cross-border questions, enable extended_thinking and use a higher effort level:
curl -X POST https://api.inwealth.fr/api/agent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_your_key_here" \
-d '{
"messages": [
{"role": "user", "content": "I am a French tax resident with a Swiss employer. How is my salary taxed? What about the double taxation treaty?"}
],
"session_id": "demo-crossborder-001",
"residence": "fr",
"language": "en",
"extended_thinking": true,
"effort": "high"
}'
Multilingual support
The agent responds in the requested language, regardless of the user’s question language or residence:
# Question in English, response in German, about Swiss taxation
curl -X POST https://api.inwealth.fr/api/agent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_your_key_here" \
-d '{
"messages": [
{"role": "user", "content": "How does the Swiss wealth tax work?"}
],
"session_id": "demo-lang-001",
"residence": "ch",
"language": "de"
}'
Token-optimized integration
Best practices to minimize token consumption in production:
{
"messages": [
{"role": "user", "content": "Your question here"}
],
"session_id": "user-123-conversation-456",
"residence": "fr",
"effort": "low"
}
Key optimizations:
- Reuse
session_id — keep the same ID across turns in a conversation. Prompt caching can reduce token costs by up to 90%.
- Set
effort explicitly — use "low" or "medium" for straightforward questions. Reserve "high" and "max" for complex scenarios.
- Trim long histories — for conversations beyond 10 turns, consider sending only the last 4-6 turns to keep input tokens low.
- Use
extended_thinking selectively — only for questions involving multiple jurisdictions or complex tax planning.