Importing TypeScript types from OpenAI in Deno: Issues Encountered

I’m working with the OpenAI library in my Deno application and facing some issues with importing types.

Initial Attempt

The documentation suggests importing from JSR like this:

import OpenAI from 'jsr:@openai/openai';

However, when I execute:

deno add jsr:@openai/openai

I receive an error indicating the package is not found. I noticed that the JSR registry doesn’t have any published versions at this time.

Current Solution

I’m currently using the npm import, which works well for the core class:

import OpenAI from "npm:openai";

The Issue

Nevertheless, when I attempt to import TypeScript interfaces:

import { ChatCompletionCreateParamsStreaming } from "npm:openai";

Deno shows a TypeScript warning stating that the exported member is missing, even though it should exist.

I’m curious about:

  • Why is the JSR package still unavailable?
  • Is this a common issue with other packages in JSR?
  • What is the correct way to import OpenAI types in Deno without encountering these warnings?

Any assistance would be greatly appreciated!

had the same prob last week. try using the type keyword: import type { ChatCompletionCreateParamsStreaming } from "npm:openai"; - it worked for me when the regular import didn’t. maybe the jsr package is still in dev or not published yet.

check your deno version first - older ones had terrible npm type support. if you’re not on the latest, upgrade now. also try clearing the cache, it fixes weird type issues like this: deno cache --reload npm:openai

Yeah, OpenAI probably doesn’t bother with JSR since npm already works fine and there’s not enough demand. The type import issue sounds like you’re running into Deno’s weird module resolution with npm packages that have messy export maps. Don’t try importing specific types directly - instead, import the main module and grab types through dot notation: const openai = new OpenAI(); type CompletionParams = Parameters<typeof openai.chat.completions.create>[0]. This way you’re using TypeScript’s inference instead of wrestling with Deno’s npm type resolution. Or just make a types.ts file and re-export the types after importing them once successfully. That gives you a clean interface and keeps all the import headaches in one spot.

Had the same issue with OpenAI in Deno recently. It’s because Deno doesn’t always pick up all the type exports from npm packages properly. For ChatCompletionCreateParamsStreaming, try running deno info npm:openai first to see what’s actually exported - sometimes the type names are different from what’s in the docs. What worked for me was importing from the deeper path: import type { ChatCompletionCreateParamsStreaming } from "npm:openai/resources/chat/completions.d.ts". As for JSR, yeah the delay is normal. Most big packages are waiting to see if JSR actually takes off before they bother publishing there. OpenAI won’t prioritize it until JSR gets more traction.

This is a common issue with npm packages in Deno - their type exports are often incomplete when imported directly. I’ve hit this with other npm packages too. Deno’s type resolution for npm imports isn’t perfect, especially with complex exports from packages that weren’t built for Deno originally. OpenAI probably hasn’t moved to JSR yet since it’s still pretty new. Most popular packages are taking their time with JSR versions. Here’s what I do as workarounds: import the entire types namespace, then grab the specific type you need. Or just use type assertions or create your own interface based on OpenAI’s docs - sometimes that’s easier than wrestling with import issues. The npm import should work fine for actual functionality even if types are broken.