Centralized respan_params initialization and backward-compat layer.
This mixin is the SINGLE initialization point for ``respan_params``.
It runs ``_initialize_respan_params()`` BEFORE ``super().initial()`` so
that by the time the throttle runs, ``respan_params`` is a fully resolved
dict. Downstream code (throttle, preprocessing, view handler) only
**enriches** the existing dict — they never need to create it.
Initialization order::
_initialize_respan_params() ← legacy rename + header parse + metadata
↓
super().initial() ← throttle ENRICHES the existing dict
↓
view handler ← billing, security strip, etc.
Responsibilities consolidated here (previously scattered across 4 callsites):
1. Legacy header rename (X-Data-Keywordsai-Params → X-Data-Respan-Params)
2. Parse X-Data-Respan-Params header (base64 → dict)
3. Legacy body rename (keywordsai_params → respan_params)
4. Form data handling (JSON string → dict)
5. Metadata nesting (passthrough endpoints — Anthropic, Google, etc.)
6. Merge: {**header_params, **body_params} (body wins on field conflict)
7. Add request_url_path from request.META['PATH_INFO']
8. Guarantee request.data[RESPAN_PARAMS_KEY] is always a dict
Safe for protobuf endpoints: body adaptation is skipped when request.data
is not a dict; header adaptation always runs.
Usage::
class MyChatView(AdaptRespanParamsMixin, APIView):
...
Request
This endpoint expects an object.
ip_addressstring or nullOptional<=100 characters
pre_commit_idstring or nullOptional<=120 characters
custom_identifierstring or nullOptional<=120 characters
group_identifierstring or nullOptional<=120 characters
blurredboolean or nullOptional
hour_groupdatetimeOptional
minute_groupdatetimeOptional
start_timedatetime or nullOptional
timestampdatetimeOptional
load_balance_group_idstringOptional<=100 characters
unique_idstring or nullOptional1-100 characters
mapped_model_namestringOptional<=255 characters
response_formatanyOptional
response_format_choicestring or nullOptional<=100 characters
parallel_tool_callsboolean or nullOptional
prompt_tokensintegerOptional-2147483648-2147483647
completion_tokensintegerOptional-2147483648-2147483647
prompt_cache_hit_tokensinteger or nullOptional-2147483648-2147483647
prompt_cache_creation_tokensinteger or nullOptional-2147483648-2147483647
total_request_tokensintegerOptional-2147483648-2147483647
input_arraylist of strings or nullOptional
encoding_formatstringOptional<=100 characters
dimensionsinteger or nullOptional-2147483648-2147483647
embeddinglist of doubles or nullOptional
base64_embeddingstring or nullOptional
audio_input_filestring or nullOptionalformat: "binary"
transcriptionstringOptional
audio_response_formatstringOptional<=100 characters
audio_output_filestring or nullOptionalformat: "binary"
prompt_messageslist of anyOptional
completion_messageanyOptional
completion_messageslist of any or nullOptional
latencydouble or nullOptional
modelstringOptional<=100 characters
calling_modelstring or nullOptional<=100 characters
foundation_modelstringOptional<=100 characters
provider_idstringOptional<=100 characters
full_model_namestring or nullOptional<=200 characters
has_tool_callsbooleanOptional
categorystringOptional<=60 characters
time_to_first_tokendouble or nullOptional
routing_timedoubleOptional
keywordsai_paramsanyOptional
session_idstringOptional<=254 characters
metadata_indexed_string_1string or nullOptional
metadata_indexed_string_2string or nullOptional
metadata_indexed_numerical_1double or nullOptional
cache_bitintegerOptional-2147483648-2147483647
cache_miss_bitinteger or nullOptional-32768-32767
cache_keystring or nullOptional<=254 characters
positive_feedbackboolean or nullOptional
tokens_per_seconddoubleOptional
status_codeintegerOptional-2147483648-2147483647
recommendationsstring or nullOptional
has_warningsbooleanOptional
error_messagestringOptional
is_examplebooleanOptional
is_maliciousbooleanOptional
log_methodenumOptional
inference - Inference
logging_api - Logging Api
batch - Batch
python_tracing - Python Tracing
ts_tracing - Ts Tracing
tracing_integration - Tracing Integration
log_typeenumOptional
text - Text
chat - Chat
completion - Completion
response - Response
embedding - Embedding
transcription - Transcription
speech - Speech
workflow - Workflow
task - Task
tool - Tool
agent - Agent
handoff - Handoff
guardrail - Guardrail
function - Function
custom - Custom
generation - Generation
unknown - Unknown
score - Score
batch - Batch
span - Span
error_bitintegerOptional-2147483648-2147483647
stream_optionsanyOptional
temperaturedouble or nullOptional
max_tokensinteger or nullOptional-2147483648-2147483647
logprobsboolean or nullOptional
top_logprobsinteger or nullOptional-2147483648-2147483647
frequency_penaltydouble or nullOptional
presence_penaltydouble or nullOptional
stopstring or nullOptional
ninteger or nullOptional-2147483648-2147483647
evaluation_identifierstring or nullOptional<=120 characters
is_datasetbooleanOptional
based_log_unique_idstring or nullOptional<=100 characters
customer_identifierstringOptional<=254 characters
customer_emailstringOptionalformat: "email"<=254 characters
customer_namestringOptional<=254 characters
customer_user_unique_idstring or nullOptional<=255 characters
used_custom_credentialbooleanOptional
deployment_namestringOptional<=254 characters
custom_endpointstring or nullOptional<=254 characters
custom_regionstring or nullOptional<=254 characters
prompt_namestring or nullOptional<=255 characters
prompt_idstringOptional<=100 characters
prompt_version_numberinteger or nullOptional-2147483648-2147483647
covered_byenumOptional
own_credential - Own Credential
user - User
credits - Credits
credit_and_credential - Credit And Credential
cache_hit - Cache Hit
credit_and_cache - Credit And Cache
system_textstring or nullOptional
prompt_textstring or nullOptional
completion_textstring or nullOptional
system_text_vectorstring or nullOptional
prompt_text_vectorstring or nullOptional
completion_text_vectorstring or nullOptional
full_text_indexedbooleanOptional
trace_unique_idstring or nullOptional<=255 characters
span_unique_idstring or nullOptional<=255 characters
trace_group_identifierstring or nullOptional<=255 characters
span_namestring or nullOptional<=100 characters
span_handoffslist of strings or nullOptional
span_toolslist of strings or nullOptional
span_parent_idstring or nullOptional<=100 characters
span_pathstring or nullOptional
span_workflow_namestring or nullOptional<=255 characters
outputstring or nullOptional
thread_identifierstringOptional<=120 characters
thread_unique_idstring or nullOptional<=255 characters
storage_object_keystring or nullOptional
error_message_searchstring or nullOptional
evaluation_costdoubleOptional
LLM_based_context_precisiondouble or nullOptional
LLM_based_faithfulnessdouble or nullOptional
flesch_reading_easedouble or nullOptional
flesch_kincaid_grade_leveldouble or nullOptional
LLM_based_answer_relevancedouble or nullOptional
amount_to_paydouble or nullOptional
full_cost_calculatedboolean or nullOptional
stripe_usage_report_sentboolean or nullOptional
to_update_threadboolean or nullOptional
to_update_customer_userboolean or nullOptional
organizationinteger or nullOptional
company_organizationinteger or nullOptional
userinteger or nullOptional
organization_keystring or nullOptional>=1 character
customer_userinteger or nullOptional
prompt_versioninteger or nullOptional
threadinteger or nullOptional
traceinteger or nullOptional
spaninteger or nullOptional
Response
ip_addressstring or null<=100 characters
pre_commit_idstring or null<=120 characters
custom_identifierstring or null<=120 characters
group_identifierstring or null<=120 characters
start_timedatetime or null
load_balance_group_idstring<=100 characters
unique_idstring or null<=100 characters
mapped_model_namestring<=255 characters
response_format_choicestring or null<=100 characters
parallel_tool_callsboolean or null
prompt_tokensinteger-2147483648-2147483647
completion_tokensinteger-2147483648-2147483647
prompt_cache_hit_tokensinteger or null-2147483648-2147483647
prompt_cache_creation_tokensinteger or null-2147483648-2147483647
total_request_tokensinteger-2147483648-2147483647
input_arraylist of strings or null
encoding_formatstring<=100 characters
dimensionsinteger or null-2147483648-2147483647
embeddinglist of doubles or null
base64_embeddingstring or null
audio_input_filestring or nullformat: "uri"
audio_response_formatstring<=100 characters
audio_output_filestring or nullformat: "uri"
prompt_messageslist of any
completion_messageslist of any or null
modelstring<=100 characters
calling_modelstring or null<=100 characters
foundation_modelstring<=100 characters
provider_idstring<=100 characters
full_model_namestring or null<=200 characters
categorystring<=60 characters
time_to_first_tokendouble or null
session_idstring<=254 characters
metadata_indexed_string_1string or null
metadata_indexed_string_2string or null
metadata_indexed_numerical_1double or null
cache_bitinteger-2147483648-2147483647
cache_miss_bitinteger or null-32768-32767
cache_keystring or null<=254 characters
positive_feedbackboolean or null
status_codeinteger-2147483648-2147483647
recommendationsstring or null
log_methodenum
inference - Inference
logging_api - Logging Api
batch - Batch
python_tracing - Python Tracing
ts_tracing - Ts Tracing
tracing_integration - Tracing Integration
log_typeenum
text - Text
chat - Chat
completion - Completion
response - Response
embedding - Embedding
transcription - Transcription
speech - Speech
workflow - Workflow
task - Task
tool - Tool
agent - Agent
handoff - Handoff
guardrail - Guardrail
function - Function
custom - Custom
generation - Generation
unknown - Unknown
score - Score
batch - Batch
span - Span
error_bitinteger-2147483648-2147483647
temperaturedouble or null
max_tokensinteger or null-2147483648-2147483647
top_logprobsinteger or null-2147483648-2147483647
frequency_penaltydouble or null
presence_penaltydouble or null
ninteger or null-2147483648-2147483647
evaluation_identifierstring or null<=120 characters
based_log_unique_idstring or null<=100 characters
customer_identifierstring<=254 characters
customer_emailstringformat: "email"<=254 characters
customer_namestring<=254 characters
customer_user_unique_idstring or null<=255 characters
used_custom_credentialboolean
deployment_namestring<=254 characters
custom_endpointstring or null<=254 characters
custom_regionstring or null<=254 characters
prompt_namestring or null<=255 characters
prompt_idstring<=100 characters
prompt_version_numberinteger or null-2147483648-2147483647
covered_byenum
own_credential - Own Credential
user - User
credits - Credits
credit_and_credential - Credit And Credential
cache_hit - Cache Hit
credit_and_cache - Credit And Cache
system_textstring or null
prompt_textstring or null
completion_textstring or null
system_text_vectorstring or null
prompt_text_vectorstring or null
completion_text_vectorstring or null
trace_unique_idstring or null<=255 characters
span_unique_idstring or null<=255 characters
trace_group_identifierstring or null<=255 characters
span_namestring or null<=100 characters
span_handoffslist of strings or null
span_toolslist of strings or null
span_parent_idstring or null<=100 characters
span_workflow_namestring or null<=255 characters
thread_identifierstring<=120 characters
thread_unique_idstring or null<=255 characters
storage_object_keystring or null
error_message_searchstring or null
LLM_based_context_precisiondouble or null
LLM_based_faithfulnessdouble or null
flesch_reading_easedouble or null
flesch_kincaid_grade_leveldouble or null
LLM_based_answer_relevancedouble or null
amount_to_paydouble or null
full_cost_calculatedboolean or null
stripe_usage_report_sentboolean or null
to_update_threadboolean or null
to_update_customer_userboolean or null
organizationinteger or null
company_organizationinteger or null
organization_keystring or null
customer_userinteger or null
prompt_versioninteger or null