Neynar Documentation
Prompt a deployment with streaming response
cURL
curl --request POST \
--url https://api.neynar.com/v2/studio/deployment/prompt/stream \
--header 'Content-Type: application/json' \
--header 'x-api-key: NEYNAR_API_DOCS' \
--data '
{
"prompt": "<string>",
"conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"deployment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fid": 3,
"images": [
{
"data": "<string>"
}
],
"name": "<string>",
"namespace": "<string>",
"session_id": "<string>"
}
'
Python
import requests
url = "https://api.neynar.com/v2/studio/deployment/prompt/stream"
payload = {
"prompt": "<string>",
"conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"deployment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fid": 3,
"images": [{ "data": "<string>" }],
"name": "<string>",
"namespace": "<string>",
"session_id": "<string>"
}
headers = {
"x-api-key": "NEYNAR_API_DOCS",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Node.js
const options = {
method: 'POST',
headers: {'x-api-key': 'NEYNAR_API_DOCS', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
conversation_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
deployment_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
fid: 3,
images: [{data: '<string>'}],
name: '<string>',
namespace: '<string>',
session_id: '<string>'
})
};
fetch('https://api.neynar.com/v2/studio/deployment/prompt/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.neynar.com/v2/studio/deployment/prompt/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'conversation_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'deployment_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'fid' => 3,
'images' => [[
'data' => '<string>'
]],
'name' => '<string>',
'namespace' => '<string>',
'session_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: NEYNAR_API_DOCS"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.neynar.com/v2/studio/deployment/prompt/stream"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"conversation_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"deployment_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fid\": 3,\n \"images\": [\n {\n \"data\": \"<string>\"\n }\n ],\n \"name\": \"<string>\",\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "NEYNAR_API_DOCS")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.neynar.com/v2/studio/deployment/prompt/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = 'NEYNAR_API_DOCS'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"conversation_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"deployment_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fid\": 3,\n \"images\": [\n {\n \"data\": \"<string>\"\n }\n ],\n \"name\": \"<string>\",\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\"}"
response = http.request(request)
puts response.read_body
Streaming Response Types
This endpoint uses Server-Sent Events (SSE) for streaming responses. The actual streaming response can include:
- SDKAssistantMessage: Claude’s responses with type
'assistant' - SDKUserMessage: User prompts with type
'user' - SDKResultMessage: Final results with type
'result'and subtypes:'success''error_max_turns''error_during_execution'
- SDKSystemMessage: System messages with type
'system'and subtype'init' - ErrorMessage: Custom error type with:
- type:
'error' - message
- timestamp
- type:
Authorizations
- x-api-key: string (header, default: NEYNAR_API_DOCS, required)
API key to authorize requests.
Body (application/json)
- prompt: string (required): Prompt string to send to the deployment.
- conversation_id: string
(optional): Conversation ID for continuation. - deployment_id: string
(required): Deployment ID. - fid: integer
(required): Farcaster ID; if not provided, namespace must be provided. Example: 3. - images: object[] (optional): Base64-encoded images for multimodal messages.
- name: string (required): Kubernetes deployment name.
- namespace: string (optional): Kubernetes namespace.
- session_id: string (optional): Claude SDK session ID.
- system_prompt_variant: enum
(optional): System prompt variant to use. Defaults to stable if not provided. Available options: canary,beta,stable.
Response
- 200: Success.