|
1 | | -# Anthropic Prompt Caching Examples (OpenRouter SDK) |
| 1 | +# Prompt Caching Examples (OpenRouter SDK) |
2 | 2 |
|
3 | | -**TODO**: Add prompt caching examples using the @openrouter/sdk package. |
| 3 | +Examples demonstrating prompt caching with @openrouter/sdk. |
4 | 4 |
|
5 | | -This directory will contain examples demonstrating Anthropic's prompt caching feature via the OpenRouter TypeScript SDK. |
| 5 | +## Documentation |
6 | 6 |
|
7 | | -## Placeholder |
| 7 | +For full prompt caching documentation including all providers, pricing, and configuration details, see: |
| 8 | +- **[Prompt Caching Guide](../../../../docs/prompt-caching.md)** |
8 | 9 |
|
9 | | -Examples will be added in a future commit. |
| 10 | +## Status |
10 | 11 |
|
11 | | -## Expected Structure |
| 12 | +**TODO**: Examples coming soon. This directory will contain: |
| 13 | +- `user-message-cache.ts` - Cache large context in user messages |
| 14 | +- `multi-message-cache.ts` - Cache system prompt across multi-turn conversations |
| 15 | +- `no-cache-control.ts` - Control scenario (validates methodology) |
12 | 16 |
|
13 | | -``` |
14 | | -prompt-caching/ |
15 | | -├── README.md # This file |
16 | | -├── system-message-cache.ts # TODO: Cache on system message |
17 | | -├── user-message-cache.ts # TODO: Cache on user message |
18 | | -├── multi-message-cache.ts # TODO: Cache in conversation |
19 | | -└── no-cache-control.ts # TODO: Control scenario |
20 | | -``` |
| 17 | +## Expected Usage |
21 | 18 |
|
22 | | -## Pattern (To Be Implemented) |
| 19 | +```typescript |
| 20 | +import OpenRouter from '@openrouter/sdk'; |
23 | 21 |
|
24 | | -The examples will use the official @openrouter/sdk package to demonstrate: |
25 | | -- How to configure cache_control with the SDK |
26 | | -- Where cache metrics appear in responses |
27 | | -- Evidence-based verification of cache behavior |
| 22 | +const openrouter = new OpenRouter({ |
| 23 | + apiKey: process.env.OPENROUTER_API_KEY, |
| 24 | +}); |
| 25 | + |
| 26 | +// Configuration and cache_control usage pattern will be documented |
| 27 | +// when examples are implemented |
| 28 | +``` |
0 commit comments