import requests
import json
url = "https://api.deepseek.com/chat/completions"
payload = json.dumps({
"messages": [
{
"content": "你是一个父亲",
"role": "system"
},
{
"content": "你好",
"role": "user"
}
],
"model": "deepseek-flash",
"thinking": {
"type": "disabled"
},
"reasoning_effort": "none",
"max_tokens": 4096,
"response_format": {
"type": "text"
},
"stop": None,
"stream": False,
"stream_options": None,
"temperature": 1,
"top_p": 1,
"tools": None,
"tool_choice": "none",
"logprobs": False,
"top_logprobs": None
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer sk-773b19c1d2aa46e788e6ae411d99f007'
}
response = requests.request("POST", url, headers=headers, data=payload)
===================
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"messages\": \\n {\\n \\"content\\": \\"You are a helpful assistant\\",\\n \\"role\\": \\"system\\"\\n },\\n {\\n \\"content\\": \\"Hi\\",\\n \\"role\\": \\"user\\"\\n }\\n ,\n \"model\": \"deepseek-flash\",\n \"thinking\": {\n \"type\": \"enabled\"\n },\n \"reasoning_effort\": \"none\",\n \"max_tokens\": 4096,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"stop\": null,\n \"stream\": false,\n \"stream_options\": null,\n \"temperature\": 1,\n \"top_p\": 1,\n \"tools\": null,\n \"tool_choice\": \"none\",\n \"logprobs\": false,\n \"top_logprobs\": null\n}");
Request request = new Request.Builder()
.url("https://api.deepseek.com/chat/completions")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer <TOKEN>")
.build();
Response response = client.newCall(request).execute();