第一弹:nvidia白嫖sd3和llama3.1
第二弹:oneapi设置使用llama3.1
代码claude随便糊的,佬们不要笑话
from flask import Flask, request, jsonify
import requests
import base64
from io import BytesIO
from datetime import datetime
from flask_cors import CORS
app = Flask(__name__)
CORS(app) # 启用CORS支持
# NVIDIA API URL 和 API Key
NVIDIA_URL = "https://ai.api.nvidia.com/v1/genai/stabilityai/stable-diffusion-3-medium"
NVIDIA_API_KEY = "" # 使用你自己的 NVIDIA API 密钥
@app.route('/v1/images/generations', methods=['POST'])
def translate_request():
data = request.json
prompt = data.get('prompt')
nvidia_payload = {
"prompt": prompt,
"cfg_scale": 5,
"aspect_ratio": "16:9",
"seed": 0,
"steps": 50,
"negative_prompt": ""
}
headers = {
"Authorization": f"Bearer {NVIDIA_API_KEY}",
"Content-Type": "application/json"
}
# 请求 NVIDIA API
response = requests.post(NVIDIA_URL, headers=headers, json=nvidia_payload)
response.raise_for_status()
response_body = response.json()
# 构造响应
adapted_response = {
"created": int(datetime.now().timestamp()),
"data": [
{
"revised_prompt":"xxxxxxx",
"b64_json": response_body['image']
}
]
}
return jsonify(adapted_response)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5001)
食用教程:
- 服务器开放5001端口
2.填入key
3.持久化运行脚本 命令:nohup python3 your_script.py > output.log 2>&1 &
4.openwebui填入url使用,密钥随便填
完结 撒花