### Call Video Generation API Source: https://context7.com/kangyiwen/dmxapi/llms.txt Provides an example of generating video content from a text prompt using the video generations endpoint. ```bash curl https://api.dmxapi.com/v1/videos/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_DMXAPI_KEY" \ -d '{ "model": "video-gen-1", "prompt": "日落时分,海浪轻轻拍打沙滩,金色阳光洒在海面上", "duration": 5, "resolution": "1080p" }' ``` -------------------------------- ### Implement RAG with LangChain Source: https://context7.com/kangyiwen/dmxapi/llms.txt Shows how to build a Retrieval-Augmented Generation (RAG) pipeline using LangChain, FAISS, and DMXAPI as the LLM and embedding provider. ```python from langchain_openai import ChatOpenAI, OpenAIEmbeddings from langchain.vectorstores import FAISS from langchain.chains import RetrievalQA from langchain.text_splitter import RecursiveCharacterTextSplitter llm = ChatOpenAI( model="gpt-4", openai_api_key="YOUR_DMXAPI_KEY", openai_api_base="https://api.dmxapi.com/v1", temperature=0 ) embeddings = OpenAIEmbeddings( openai_api_key="YOUR_DMXAPI_KEY", openai_api_base="https://api.dmxapi.com/v1" ) documents = ["您的文档内容..."] text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200) texts = text_splitter.create_documents(documents) vectorstore = FAISS.from_documents(texts, embeddings) qa_chain = RetrievalQA.from_chain_type( llm=llm, chain_type="stuff", retriever=vectorstore.as_retriever(search_kwargs={"k": 3}) ) ``` -------------------------------- ### Integrate DMXAPI with Python SDK Source: https://context7.com/kangyiwen/dmxapi/llms.txt Demonstrates using the official OpenAI Python SDK to interact with DMXAPI by configuring the base_url. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_DMXAPI_KEY", base_url="https://api.dmxapi.com/v1" ) def chat_with_model(user_message, model="gpt-4"): try: response = client.chat.completions.create( model=model, messages=[ {"role": "system", "content": "你是一个专业的AI助手。"}, {"role": "user", "content": user_message} ], temperature=0.7, max_tokens=2000 ) return response.choices[0].message.content except Exception as e: print(f"API调用错误: {e}") return None ``` -------------------------------- ### Call Image Generation API Source: https://context7.com/kangyiwen/dmxapi/llms.txt Shows how to generate images using models like DALL-E 3 by sending a prompt to the images generations endpoint. ```bash curl https://api.dmxapi.com/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_DMXAPI_KEY" \ -d '{ "model": "dall-e-3", "prompt": "一只可爱的卡通熊猫在竹林中吃竹子,水彩画风格", "n": 1, "size": "1024x1024", "quality": "standard" }' ``` -------------------------------- ### POST /v1/videos/generations Source: https://context7.com/kangyiwen/dmxapi/llms.txt Generate video content from text descriptions. ```APIDOC ## POST /v1/videos/generations ### Description Generate a video based on a text prompt. ### Method POST ### Endpoint https://api.dmxapi.com/v1/videos/generations ### Parameters #### Request Body - **model** (string) - Required - The video generation model. - **prompt** (string) - Required - Description of the video. - **duration** (integer) - Optional - Length in seconds. ### Request Example { "model": "video-gen-1", "prompt": "Sunset at the beach", "duration": 5 } ### Response #### Success Response (200) - **id** (string) - Job ID for the video generation task. - **status** (string) - Current status of the request. ``` -------------------------------- ### POST /v1/audio/speech Source: https://context7.com/kangyiwen/dmxapi/llms.txt Convert text into natural-sounding speech using TTS models. ```APIDOC ## POST /v1/audio/speech ### Description Synthesize speech from text input. ### Method POST ### Endpoint https://api.dmxapi.com/v1/audio/speech ### Parameters #### Request Body - **model** (string) - Required - The TTS model to use. - **input** (string) - Required - The text to convert to speech. - **voice** (string) - Required - The voice profile to use. ### Request Example { "model": "tts-1", "input": "Hello world", "voice": "alloy" } ### Response #### Success Response (200) - Returns a binary MP3 audio stream. ``` -------------------------------- ### Call LLM Text Generation API Source: https://context7.com/kangyiwen/dmxapi/llms.txt Demonstrates how to perform text generation using the OpenAI-compatible chat completions endpoint via curl. It requires an API key and supports various models like gpt-4. ```bash curl https://api.dmxapi.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_DMXAPI_KEY" \ -d '{ "model": "gpt-4", "messages": [ {"role": "system", "content": "你是一个有帮助的助手。"}, {"role": "user", "content": "请用简短的话介绍人工智能的发展历史。"} ], "temperature": 0.7, "max_tokens": 1000 }' ``` -------------------------------- ### POST /v1/chat/completions Source: https://context7.com/kangyiwen/dmxapi/llms.txt Generate text responses using various LLMs like GPT-4 or Claude via a unified chat interface. ```APIDOC ## POST /v1/chat/completions ### Description Generate text completions or engage in multi-turn conversations with supported LLMs. ### Method POST ### Endpoint https://api.dmxapi.com/v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The ID of the model to use (e.g., "gpt-4"). - **messages** (array) - Required - A list of messages comprising the conversation. - **temperature** (float) - Optional - Sampling temperature (0-2). - **max_tokens** (integer) - Optional - Maximum tokens to generate. ### Request Example { "model": "gpt-4", "messages": [{"role": "user", "content": "Explain AI history."}] } ### Response #### Success Response (200) - **id** (string) - Unique identifier for the completion. - **choices** (array) - List of generated message choices. #### Response Example { "id": "chatcmpl-xxx", "choices": [{"message": {"role": "assistant", "content": "..."}}] } ``` -------------------------------- ### POST /v1/images/generations Source: https://context7.com/kangyiwen/dmxapi/llms.txt Generate high-quality images from text prompts using models like DALL-E or Stable Diffusion. ```APIDOC ## POST /v1/images/generations ### Description Create images based on a text prompt. ### Method POST ### Endpoint https://api.dmxapi.com/v1/images/generations ### Parameters #### Request Body - **model** (string) - Required - The model to use (e.g., "dall-e-3"). - **prompt** (string) - Required - Text description of the image. - **size** (string) - Optional - Image dimensions (e.g., "1024x1024"). ### Request Example { "model": "dall-e-3", "prompt": "A cute cartoon panda", "size": "1024x1024" } ### Response #### Success Response (200) - **data** (array) - List of generated image URLs. #### Response Example { "data": [{"url": "https://api.dmxapi.com/files/img-xxx.png"}] } ``` -------------------------------- ### Call TTS Speech Synthesis API Source: https://context7.com/kangyiwen/dmxapi/llms.txt Demonstrates converting text to speech using the audio speech endpoint, saving the output directly to an MP3 file. ```bash curl https://api.dmxapi.com/v1/audio/speech \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_DMXAPI_KEY" \ -d '{ "model": "tts-1", "input": "欢迎使用 DMXAPI,全球领先的大模型 API 聚合服务。", "voice": "alloy", "response_format": "mp3", "speed": 1.0 }' \ --output speech.mp3 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.