Hugging Face
Access the Hugging Face Inference API and its vast open-source model hub through Yunxin.
Overview
Hugging Face hosts one of the largest open-source AI model hubs, and its Inference API exposes hosted models for text generation, embeddings, image, audio, and more. Yunxin routes requests to Hugging Face Inference behind a single OpenAI-compatible endpoint.
Official Website: https://huggingface.co Documentation: https://huggingface.co/docs/inference-providers
Key features
- Huge model hub — Access to a large catalog of community- and lab-published models
- Serverless inference — No infrastructure to manage
- Multiple modalities — Chat, embeddings, image generation, and TTS/STT depending on the model
- Vision & tools — Some models support image input and function calling
- Open ecosystem — Models from leading AI labs and the wider community
Using Hugging Face with Yunxin
Address Hugging Face models with the huggingface/<model> prefix in the model field. You use the same Yunxin base URL (https://api.yuhuanstudio.com/v1) and your sk- API key — there is no separate Hugging Face configuration on your side.
Capabilities vary by model. Query GET /v1/models to discover which models are available and what each one supports.
Usage example
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YUNXIN_API_KEY"],
base_url="https://api.yuhuanstudio.com/v1"
)
response = client.chat.completions.create(
model="huggingface/model-id",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.YUNXIN_API_KEY,
baseURL: "https://api.yuhuanstudio.com/v1",
});
const response = await client.chat.completions.create({
model: "huggingface/model-id",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello!" },
],
});
console.log(response.choices[0].message.content);curl https://api.yuhuanstudio.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YUNXIN_API_KEY" \
-d '{
"model": "huggingface/model-id",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'Available models
Query the Models API for the current list and per-model capabilities:
curl "https://api.yuhuanstudio.com/v1/models?provider=huggingface" \
-H "Authorization: Bearer $YUNXIN_API_KEY"Capabilities and pricing are defined per model. Use GET /v1/models (and GET /v1/models/{model_id}) to discover the authoritative model list, supported features, and current rates.
Official resources
How is this guide?