bad error on VJP of functions returning typed key arrays
Found by @NeilGirdhar in #14046!

```python
from jax import enable_custom_prng, vjp
from jax.random import PRNGKey

with enable_custom_prng():
    def f(i):
        return PRNGKey(i)

    out, f_vjp = vjp(f, 1)  # Fails!
```
Error is:
```
TypeError: Value 'PRNGKeyArray[fry] { [0 1] }' with dtype key<fry> is not a valid JAX array type. Only arrays of numeric types are supported by JAX.
```

cc #9263
diff --git a/jax/_src/dtypes.py b/jax/_src/dtypes.py
index 42d73877e..af9512dcd 100644
--- a/jax/_src/dtypes.py
+++ b/jax/_src/dtypes.py
@@ -617,10 +617,10 @@ def dtype(x: Any, *, canonicalize: bool = False) -> DType:
       dt = np.result_type(x)
     except TypeError as err:
       raise TypeError(f"Cannot determine dtype of {x}") from err
-  if dt not in _jax_dtype_set:
+  if dt not in _jax_dtype_set and not core.is_opaque_dtype(dt):
     raise TypeError(f"Value '{x}' with dtype {dt} is not a valid JAX array "
                     "type. Only arrays of numeric types are supported by JAX.")
-  return canonicalize_dtype(dt) if canonicalize else dt
+  return canonicalize_dtype(dt, allow_opaque_dtype=True) if canonicalize else dt
 
 def _lattice_result_type(*args: Any) -> Tuple[DType, bool]:
   dtypes, weak_types = zip(*(_dtype_and_weaktype(arg) for arg in args))
diff --git a/tests/random_test.py b/tests/random_test.py
index 6a629c0ee..bb056116d 100644
--- a/tests/random_test.py
+++ b/tests/random_test.py
@@ -526,6 +526,11 @@ class PrngTest(jtu.JaxTestCase):
     key = random.PRNGKey(0)
     self.assertIsInstance(key, jax.Array)
 
+  def test_key_output_vjp(self):
+    # See https://github.com/google/jax/issues/14856
+    def f(seed): return random.PRNGKey(seed)
+    jax.vjp(f, 1)  # doesn't crash
+
 
 class ThreefryPrngTest(jtu.JaxTestCase):
   def test_seed_no_implicit_transfers(self):
['jax/_src/dtypes.py', 'tests/random_test.py']