YuhuanStudioYunUIDocs
Patterns

Code Demo

A ready-made tabbed code sample for calling an OpenAI-compatible API (Python, Node.js, cURL).

A ready-made, tabbed code sample showing how to call an OpenAI-compatible API from Python, Node.js, and cURL. It is a self-contained showcase block built on CodeBlock (with tab switching and copy-to-clipboard) — useful for an API landing page or quickstart.

Import

import { CodeDemo } from "@yuhuanowo/yunui/patterns";

Example

CodeDemo takes no props — the snippets and tabs are built in. Drop it straight into the page.

CodeDemo

1import openai
2 
3client = openai.OpenAI(
4 base_url="https://api.example.com/v1",
5 api_key="your_api_key"
6)
7 
8response = client.chat.completions.create(
9 model="deepseek-r1",
10 messages=[{"role": "user", "content": "Hello!"}]
11)
12 
13print(response.choices[0].message.content)

On this page