Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Deno 7 min read How-to mediumAdept

Getting Started with the OpenAI SDK for Deno

OpenAI's official Deno SDK on deno.land/x is a TypeScript-first module loaded over HTTPS, which makes loading more efficient on edge platforms like Deno Deploy, Netlify and Supabase and gives VS Code type support without extra configuration. The walkthrough covers installing the SDK through an import map in deno.jsonc and setting OPENAI_API_KEY. It then builds three examples: text generation with GPT-4 Turbo, a single-file Hono JSX app that generates images with DALL-E 3, and image analysis with gpt-4-vision-preview through the chat completions API.

Assumes: TypeScript basicsDeno runtime basics

Related posts

  • The Dino 🦕, the Llama 🦙, and the Whale 🐋

    Deno mediumAdept

    Deno's built-in Jupyter kernel, Ollama and LangChain.js combine into a low-friction environment for experimenting with a locally hosted DeepSeek R1 8B model in TypeScript. The walkthrough covers pulling the model with Ollama, creating a Deno-kernel notebook in VSCode, and building a LangChain RunnableSequence that pairs a prompt template with a zod-backed StructuredOutputParser so responses come back as validated JSON. It also renders the chain as a Mermaid diagram inside the notebook. Most of the setup effort goes into running the model locally, and the same chain could point at a hosted API like OpenAI or Anthropic instead.

  • Making a web app generator with open ML models

    Hugging Face mediumAdept

    A Node.js/Express server can generate web apps from a text prompt by streaming tokens from a code LLM (WizardCoder-15B on Hugging Face Inference Endpoints) straight into the browser as HTML. Prompt tuning does most of the work: terse imperative instructions, pre-seeding the output with `<html><body class=...>`, and requiring TailwindCSS so styles arrive inline without a stylesheet that stalls rendering. Image URLs come from a Stable Diffusion `/image` endpoint that the model is told to call. Alpine.js provides a minimal UI, and DaisyUI's shorthand classes cut token usage compared with verbose Tailwind utility classes.

  • Mozilla Llamafile in Supabase Edge Functions

    Supabase mediumAdept

    Supabase Edge Functions can now use Mozilla Llamafile, alongside Ollama, as the inference server via an OpenAI-API-compatible mode. Setup takes one of two paths. You can set AI_INFERENCE_API_HOST and call Supabase.ai.Session with mode 'openaicompatible'. Or you can point the OpenAI Deno SDK at the Llamafile server through OPENAI_BASE_URL and stream responses back as server-sent events. With the SDK, the model parameter is ignored because the model is whichever Llamafile is running. The walkthrough covers local serving with the Supabase CLI, deploying a containerized Llamafile to a host like Fly.io, and setting secrets to deploy the functions.

  • Build a REST API with Express, TypeScript, and Deno

    Deno mediumAdept

    Deno runs Express with TypeScript without any TypeScript build configuration: Express is imported through an npm: specifier and its types are pulled in with a @deno-types comment. The walkthrough sets up a server that reads its port from the environment and starts it with explicit Deno permissions (--allow-read, --allow-net, --allow-env), which limits what third-party code can access. It also defines dev and start tasks in deno.jsonc, adds a request-logging middleware, and serves mock user data imported as JSON through /users and /users/:id routes, giving a REST API starting point in under 30 lines.

  • Deno 1.34: deno compile supports npm packages

    Deno mediumAdept

    Deno 1.34 lets `deno compile` bundle npm packages and their dependencies into a single self-contained executable. That makes tools like vite and eslint shippable as binaries with pinned dependencies, and they tend to start faster than running from a local cache. The release also adds cross-platform glob support in deno.json, deno task and CLI flags, and TLS certificates with IP addresses via rustls. Smaller changes include a top-level `exclude` and `nodeModulesDir` in config, configurable language-server limits, a `Deno.serve()` signature change that returns a `Deno.Server`, new `createHttpClient` pool options, more Node.js polyfills, and upgrades to V8 11.5 and TypeScript 5.0.4.

The quest for software engineering knowledge.

Look:
Layout: