docs: Add AI/ML API example#61
Conversation
|
Thanks. I will be reviewing this over the weekend. |
|
@mishushakov hi! Can i get a review here pls? Thanks! |
There was a problem hiding this comment.
Hey @D1m7asis, some points:
-
I have tried running the JS example with my own API key and got this:
❌ Error: 2 | import { castToError } from "./core.mjs"; 3 | export class OpenAIError extends Error { 4 | } 5 | export class APIError extends OpenAIError { 6 | constructor(status, error, message, headers) { 7 | super(`${APIError.makeMessage(status, error, message)}`); ^ error: 403 status code (no body)
What am I doing wrong?
-
Can you make sure the example is same for both JS and Python?
-
I see that the examples are using
gpt-3.5-turbo- can you use a more recent model, as not a lot of people would be starting with GPT-3.5 today
Improved the JavaScript and Python AIML API example scripts for clarity, modularity, and robustness. Updated documentation for both examples, clarified model usage, and added a sample data.csv file for reproducible data science tasks. The JS and Python scripts now better extract and execute code from LLM responses, handle datasets, and save generated images.
|
Hey @mishushakov, thanks for the feedback 🙌 I’ve fixed the issues: Everything works now and the examples are identical across both languages 🚀 |
|
@mishushakov @tizkovatereza hi guys! a reminder to check on the PR :) |
mishushakov
left a comment
There was a problem hiding this comment.
left some comments regarding getting the stdout of the sandbox
Refactored JS and Python examples to streamline code execution in sandboxes, removing manual stdout/stderr collation and using the first result's text and image directly. Updated .env.example to include AIML_API_KEY and fixed README to link to the TypeScript example for AIML API.
|
@mishushakov thanks for the review 🙌 |
|
@mishushakov let us know if there is any other changes that need to be implemented |
|
Hi! Following up on this cookbook example. The PR is still mergeable but has stale requested changes around example consistency/model choice/output handling. We can refresh it with the current recommended AI/ML API model, keep the Python and JS examples aligned, and make the sandbox stdout handling match the project style. Please let me know if you would still like this example in the cookbook and I’ll update the branch accordingly. |
🔄 Summary
This PR adds support for AI/ML API, an OpenAI-compatible provider offering 300+ models (e.g., DeepSeek, Gemini, ChatGPT), to the E2B Code Interpreter examples.
✅ What's Included
examples/aimlapi-js/: TypeScript example using E2B sandbox + AI/ML API via OpenAI SDKexamples/aimlapi-python/: Python version usingopenaiande2b-code-interpreter.env.template,README.md, and dependency setup for each variantREADME.mdwith proper UTM trackingLet me know if you'd like the examples styled/formatted differently — happy to iterate!