ai
ai copied to clipboard
Rendering a mock stream so that avoiding unecessary API calls
Feature Description
I'm familiarizing with this new tool and it's unpractical having to trigger an api call to OpenAI each time I want to try something new. I would like to have the option of render a mock stream.
Use Case
Cost efficient development
Additional context
No response
One option is to record and playback your OpenAI response, see this Gist for example: https://gist.github.com/unstubbable/ffa9028fcb6ea6f218579e9e7cebd403
Thanks Hendrik!
This can already be done, you can easily implement your own providers. During dev you can use the mock provider. Look at some of the community providers that are available.
https://sdk.vercel.ai/providers/community-providers/custom-providers#:~:text=You%20can%20write%20your%20own,to%20implement%20a%20custom%20provider.
https://github.com/vercel/ai/tree/main/packages/mistral
Use GPT to have it change the code for you. Use Calude Opus and put this in your prompt
think step by step, provide full code. Ensure you write strongly typed, immutable and declarative code. It is important to continue to following existing established best practices. After you’ve written the code review it against the original and provide feedback on how you can improve to be consistent with established conventions.
Mock models are now exposed: https://sdk.vercel.ai/docs/ai-sdk-core/testing