File size: 689 Bytes
2952395
203836b
 
2952395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import requests

# API调用函数
def call_api(user_input):
    url = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"  # 替换为你的API URL
    headers = {"Authorization": "Bearer YOUR_TOKEN"}
    params = {"query": user_input}

    response = requests.get(url, headers=headers, params=params)
    if response.status_code == 200:
        return response.json()  # 返回API的响应
    else:
        return f"Error: {response.status_code}"

# 使用Gradio界面
iface = gr.Interface(
    fn=call_api, 
    inputs="text", 
    outputs="json",
    title="API 调用",
    description="输入文本并从API获取结果"
)

iface.launch()